[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 03/13] x86/HV: Add new hvcall guest address host visibility support



On 7/28/21 7:52 AM, Tianyu Lan wrote:
> @@ -1986,7 +1988,9 @@ static int __set_memory_enc_dec(unsigned long addr, int 
> numpages, bool enc)
>       int ret;
>  
>       /* Nothing to do if memory encryption is not active */
> -     if (!mem_encrypt_active())
> +     if (hv_is_isolation_supported())
> +             return hv_set_mem_enc(addr, numpages, enc);
> +     else if (!mem_encrypt_active())
>               return 0;

One more thing.  If you're going to be patching generic code, please
start using feature checks that can get optimized away at runtime.
hv_is_isolation_supported() doesn't look like the world's cheapest
check.  It can't be inlined and costs at least a function call.

These checks could, with basically no effort be wrapped in a header like
this:

static inline bool hv_is_isolation_supported(void)
{
        if (!cpu_feature_enabled(X86_FEATURE_HYPERVISOR))
                return 0;

        // out of line function call:
        return __hv_is_isolation_supported();
}       

I don't think it would be the end of the world to add an
X86_FEATURE_HYPERV_GUEST, either.  There are plenty of bits allocated
for Xen and VMWare.



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.