[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <76952ed2-9fee-eae9-c9f3-5a7dd0fc1153@gmail.com>
Date: Thu, 15 Dec 2022 00:02:44 +0800
From: Tianyu Lan <ltykernel@...il.com>
To: "Michael Kelley (LINUX)" <mikelley@...rosoft.com>,
"luto@...nel.org" <luto@...nel.org>,
"tglx@...utronix.de" <tglx@...utronix.de>,
"mingo@...hat.com" <mingo@...hat.com>,
"bp@...en8.de" <bp@...en8.de>,
"dave.hansen@...ux.intel.com" <dave.hansen@...ux.intel.com>,
"x86@...nel.org" <x86@...nel.org>, "hpa@...or.com" <hpa@...or.com>,
"seanjc@...gle.com" <seanjc@...gle.com>,
"pbonzini@...hat.com" <pbonzini@...hat.com>,
"jgross@...e.com" <jgross@...e.com>,
Tianyu Lan <Tianyu.Lan@...rosoft.com>,
"kirill@...temov.name" <kirill@...temov.name>,
"jiangshan.ljs@...group.com" <jiangshan.ljs@...group.com>,
"peterz@...radead.org" <peterz@...radead.org>,
"ashish.kalra@....com" <ashish.kalra@....com>,
"srutherford@...gle.com" <srutherford@...gle.com>,
"akpm@...ux-foundation.org" <akpm@...ux-foundation.org>,
"anshuman.khandual@....com" <anshuman.khandual@....com>,
"pawan.kumar.gupta@...ux.intel.com"
<pawan.kumar.gupta@...ux.intel.com>,
"adrian.hunter@...el.com" <adrian.hunter@...el.com>,
"daniel.sneddon@...ux.intel.com" <daniel.sneddon@...ux.intel.com>,
"alexander.shishkin@...ux.intel.com"
<alexander.shishkin@...ux.intel.com>,
"sandipan.das@....com" <sandipan.das@....com>,
"ray.huang@....com" <ray.huang@....com>,
"brijesh.singh@....com" <brijesh.singh@....com>,
"michael.roth@....com" <michael.roth@....com>,
"thomas.lendacky@....com" <thomas.lendacky@....com>,
"venu.busireddy@...cle.com" <venu.busireddy@...cle.com>,
"sterritt@...gle.com" <sterritt@...gle.com>,
"tony.luck@...el.com" <tony.luck@...el.com>,
"samitolvanen@...gle.com" <samitolvanen@...gle.com>,
"fenghua.yu@...el.com" <fenghua.yu@...el.com>
Cc: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"kvm@...r.kernel.org" <kvm@...r.kernel.org>,
"linux-hyperv@...r.kernel.org" <linux-hyperv@...r.kernel.org>,
"linux-arch@...r.kernel.org" <linux-arch@...r.kernel.org>
Subject: Re: [RFC PATCH V2 06/18] x86/hyperv: Use vmmcall to implement hvcall
in sev-snp enlightened guest
On 12/14/2022 1:19 AM, Michael Kelley (LINUX) wrote:
> From: Tianyu Lan <ltykernel@...il.com> Sent: Friday, November 18, 2022 7:46 PM
>>
>> In sev-snp enlightened guest, hvcall needs to use vmmcall to trigger
>
> What does "hvcall" refer to here? Is this a Hyper-V hypercall, or just
> a generic hypervisor call?
It's should be Hyper-V hypercall. Will make it accurate in the next
version. Thanks for reminder.
>
>> vmexit and notify hypervisor to handle hypercall request.
>>
>> Signed-off-by: Tianyu Lan <tiala@...rosoft.com>
>> ---
>> arch/x86/include/asm/mshyperv.h | 66 ++++++++++++++++++++++-----------
>> 1 file changed, 45 insertions(+), 21 deletions(-)
>>
>> diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h
>> index 9b8c3f638845..28d5429e33c9 100644
>> --- a/arch/x86/include/asm/mshyperv.h
>> +++ b/arch/x86/include/asm/mshyperv.h
>> @@ -45,16 +45,25 @@ static inline u64 hv_do_hypercall(u64 control, void *input, void *output)
>> u64 hv_status;
>>
>> #ifdef CONFIG_X86_64
>> - if (!hv_hypercall_pg)
>> - return U64_MAX;
>> + if (hv_isolation_type_en_snp()) {
>> + __asm__ __volatile__("mov %4, %%r8\n"
>> + "vmmcall"
>> + : "=a" (hv_status), ASM_CALL_CONSTRAINT,
>> + "+c" (control), "+d" (input_address)
>> + : "r" (output_address)
>> + : "cc", "memory", "r8", "r9", "r10", "r11");
>> + } else {
>> + if (!hv_hypercall_pg)
>> + return U64_MAX;
>>
>> - __asm__ __volatile__("mov %4, %%r8\n"
>> - CALL_NOSPEC
>> - : "=a" (hv_status), ASM_CALL_CONSTRAINT,
>> - "+c" (control), "+d" (input_address)
>> - : "r" (output_address),
>> - THUNK_TARGET(hv_hypercall_pg)
>> - : "cc", "memory", "r8", "r9", "r10", "r11");
>> + __asm__ __volatile__("mov %4, %%r8\n"
>> + CALL_NOSPEC
>> + : "=a" (hv_status), ASM_CALL_CONSTRAINT,
>> + "+c" (control), "+d" (input_address)
>> + : "r" (output_address),
>> + THUNK_TARGET(hv_hypercall_pg)
>> + : "cc", "memory", "r8", "r9", "r10", "r11");
>> + }
>> #else
>> u32 input_address_hi = upper_32_bits(input_address);
>> u32 input_address_lo = lower_32_bits(input_address);
>> @@ -82,12 +91,18 @@ static inline u64 hv_do_fast_hypercall8(u16 code, u64 input1)
>> u64 hv_status, control = (u64)code | HV_HYPERCALL_FAST_BIT;
>>
>> #ifdef CONFIG_X86_64
>> - {
>> + if (hv_isolation_type_en_snp()) {
>> + __asm__ __volatile__(
>> + "vmmcall"
>> + : "=a" (hv_status), ASM_CALL_CONSTRAINT,
>> + "+c" (control), "+d" (input1)
>> + :: "cc", "r8", "r9", "r10", "r11");
>> + } else {
>> __asm__ __volatile__(CALL_NOSPEC
>> - : "=a" (hv_status), ASM_CALL_CONSTRAINT,
>> - "+c" (control), "+d" (input1)
>> - : THUNK_TARGET(hv_hypercall_pg)
>> - : "cc", "r8", "r9", "r10", "r11");
>> + : "=a" (hv_status), ASM_CALL_CONSTRAINT,
>> + "+c" (control), "+d" (input1)
>> + : THUNK_TARGET(hv_hypercall_pg)
>> + : "cc", "r8", "r9", "r10", "r11");
>
> The above 4 lines appear to just have changes in indentation. Maybe
> there's value in having the same indentation as the new code you've
> added, so I won't object if you want to keep the changes.
OK. Will update in the next version.
>
>> }
>> #else
>> {
>> @@ -113,14 +128,21 @@ static inline u64 hv_do_fast_hypercall16(u16 code, u64 input1, u64 input2)
>> u64 hv_status, control = (u64)code | HV_HYPERCALL_FAST_BIT;
>>
>> #ifdef CONFIG_X86_64
>> - {
>> + if (hv_isolation_type_en_snp()) {
>> __asm__ __volatile__("mov %4, %%r8\n"
>> - CALL_NOSPEC
>> - : "=a" (hv_status), ASM_CALL_CONSTRAINT,
>> - "+c" (control), "+d" (input1)
>> - : "r" (input2),
>> - THUNK_TARGET(hv_hypercall_pg)
>> - : "cc", "r8", "r9", "r10", "r11");
>> + "vmmcall"
>> + : "=a" (hv_status), ASM_CALL_CONSTRAINT,
>> + "+c" (control), "+d" (input1)
>> + : "r" (input2)
>> + : "cc", "r8", "r9", "r10", "r11");
>> + } else {
>> + __asm__ __volatile__("mov %4, %%r8\n"
>> + CALL_NOSPEC
>> + : "=a" (hv_status), ASM_CALL_CONSTRAINT,
>> + "+c" (control), "+d" (input1)
>> + : "r" (input2),
>> + THUNK_TARGET(hv_hypercall_pg)
>> + : "cc", "r8", "r9", "r10", "r11");
>
Powered by blists - more mailing lists