All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mukesh R <mrathor@linux.microsoft.com>
To: Michael Kelley <mhklinux@outlook.com>,
	"linux-hyperv@vger.kernel.org" <linux-hyperv@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Cc: "haiyangz@microsoft.com" <haiyangz@microsoft.com>,
	"wei.liu@kernel.org" <wei.liu@kernel.org>,
	"decui@microsoft.com" <decui@microsoft.com>,
	"mhkelley58@gmail.com" <mhkelley58@gmail.com>
Subject: Re: [PATCH V0 1/2] Drivers: hv: Add new function hv_isolation_hw_cvm()
Date: Wed, 11 Nov 2026 15:09:16 -0800	[thread overview]
Message-ID: <488ac669-eeb6-4873-217d-da111d58eb09@linux.microsoft.com> (raw)
In-Reply-To: <MN2PR02MB68638A29ED39B5D77EF34616D4712@MN2PR02MB6863.namprd02.prod.outlook.com>

On 11/11/26 10:09, Michael Kelley wrote:
> From: Mukesh R <mrathor@linux.microsoft.com> Sent: Tuesday, November 10, 2026 6:21 PM
>>
>> Add a new function hv_isolation_hw_cvm() for convenient check
>> if a VM is running in HW confidential mode, ie, TDX or SNP.
>>
>> Signed-off-by: Mukesh R <mrathor@linux.microsoft.com>
>> ---
>>   arch/x86/hyperv/ivm.c          | 5 +++++
>>   drivers/hv/hv_common.c         | 9 +++++++--
>>   include/asm-generic/mshyperv.h | 7 +++++++
>>   3 files changed, 19 insertions(+), 2 deletions(-)
>>
>> diff --git a/arch/x86/hyperv/ivm.c b/arch/x86/hyperv/ivm.c
>> index 2ce4dfe53472..b3340be0c43a 100644
>> --- a/arch/x86/hyperv/ivm.c
>> +++ b/arch/x86/hyperv/ivm.c
>> @@ -944,3 +944,8 @@ bool hv_isolation_type_tdx(void)
>>   {
>>   	return static_branch_unlikely(&isolation_type_tdx);
>>   }
>> +
>> +bool hv_isolation_hw_cvm(void)
>> +{
>> +	return hv_isolation_type_snp() || hv_isolation_type_tdx();
>> +}
>> diff --git a/drivers/hv/hv_common.c b/drivers/hv/hv_common.c
>> index 27b9b79d4f4c..62b52855ae69 100644
>> --- a/drivers/hv/hv_common.c
>> +++ b/drivers/hv/hv_common.c
>> @@ -528,8 +528,7 @@ int hv_common_cpu_init(unsigned int cpu)
>>   			*outputarg = (char *)mem + HV_HYP_PAGE_SIZE;
>>   		}
>>
>> -		if (!ms_hyperv.paravisor_present &&
>> -		    (hv_isolation_type_snp() || hv_isolation_type_tdx())) {
>> +		if (!ms_hyperv.paravisor_present && hv_isolation_hw_cvm()) {
> 
> Any reason not to use hv_is_isolation_supported()? Your
> new function seems conceptually equivalent, though at a
> detailed level it handles VBS isolation differently from
> hv_is_isolation_supported(). But I don't think including
> VBS isolation here is a problem since set_memory_decrypted()
> is a no-op with VBS isolation.
> 
> Also, Kameron Carr has a patch set in flight that collides
> on exactly this code.  See [1] for the patch and my comments.
> 
> Michael

Hi Michael,

The issues my patch addresses only apply to hardware isolations, like
TDX and SNP, hence I called the function: hv_isolation_hw_cvm()

IOW, hv_is_isolation_supported() cannot be used in my case.

If there is conflict, I guess, one of us will have to rebase depending
on who merges first.

Thanks,
-Mukesh


> [1] https://lore.kernel.org/linux-hyperv/MN2PR02MB6863AA6357C8E0D4881F5FEAD4712@MN2PR02MB6863.namprd02.prod.outlook.com/
> 
> 
>>   			ret = set_memory_decrypted((unsigned long)mem, pgcount);
>>   			if (ret) {
>>   				/* It may be unsafe to free 'mem' */
>> @@ -696,6 +695,12 @@ bool __weak hv_isolation_type_tdx(void)
>>   }
>>   EXPORT_SYMBOL_GPL(hv_isolation_type_tdx);
>>
>> +bool __weak hv_isolation_hw_cvm(void)
>> +{
>> +	return false;
>> +}
>> +EXPORT_SYMBOL_GPL(hv_isolation_hw_cvm);
>> +
>>   void __weak hv_setup_vmbus_handler(void (*handler)(void))
>>   {
>>   }
>> diff --git a/include/asm-generic/mshyperv.h b/include/asm-generic/mshyperv.h
>> index a3d497d99b0b..440c599784eb 100644
>> --- a/include/asm-generic/mshyperv.h
>> +++ b/include/asm-generic/mshyperv.h
>> @@ -87,6 +87,13 @@ u64 hv_do_fast_hypercall16(u16 control, u64 input1, u64
>> input2);
>>   bool hv_isolation_type_snp(void);
>>   bool hv_isolation_type_tdx(void);
>>
>> +/* This needs to be before hv_do_rep_hypercall() below */
>> +#if IS_ENABLED(CONFIG_HYPERV)
>> +bool hv_isolation_hw_cvm(void);
>> +#else
>> +static inline bool hv_isolation_hw_cvm(void) { return false; }
>> +#endif
>> +
>>   /*
>>    * On architectures where Hyper-V doesn't support AEOI (e.g., ARM64),
>>    * it doesn't provide a recommendation flag and AEOI must be disabled.
>> --
>> 2.51.2.vfs.0.1
>>


  reply	other threads:[~2026-11-11 23:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-11  2:20 [PATCH V0 0/2] Hyper-V: Fix bugs and issues around repeat hypercall Mukesh R
2026-11-11  2:20 ` [PATCH V0 1/2] Drivers: hv: Add new function hv_isolation_hw_cvm() Mukesh R
2026-11-11 18:09   ` Michael Kelley
2026-11-11 23:09     ` Mukesh R [this message]
2026-11-11  2:20 ` [PATCH V0 2/2] Drivers: hv: Fix bugs and issues around repeat hypercall Mukesh R

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=488ac669-eeb6-4873-217d-da111d58eb09@linux.microsoft.com \
    --to=mrathor@linux.microsoft.com \
    --cc=decui@microsoft.com \
    --cc=haiyangz@microsoft.com \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhkelley58@gmail.com \
    --cc=mhklinux@outlook.com \
    --cc=wei.liu@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.