Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp2875102pxb; Tue, 24 Aug 2021 09:36:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzvkW/lPDlizOoI+whcYZSZWrRiPaYz8j5HdqjjQjCQHNJ622qwpDdRGnR500eIxBpreiRx X-Received: by 2002:a17:906:b890:: with SMTP id hb16mr40528202ejb.383.1629822970510; Tue, 24 Aug 2021 09:36:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629822970; cv=none; d=google.com; s=arc-20160816; b=K8jwaKvoikuAuc6cdgDNYE7sy9VyuwEor7oZAdQne7gs+b5Fnfwe/F8FcdpTjBQ72K lckxAWUREvhbVQmMwOk5dsNjwg4Omwt5fxEv4R0l4ww0b7bpP4seQL2tJ6R4R96rtJRy 9UOZ5ic+d7nBarZ6ARhAEEYNAoXeowS38/WdPa1ei/AR89fTGEjei9gkSR9JlnUD31/l z1OnNQqA4Q0ERti/XcHZ8U6FRzZzIzEVNhVoXLqKYpjz7RTIejrXlby29PbRTTGQm8sx VdvnBaQq+I2CI/MUTC//qlQ6tGz3kmROw/jGASOECUWam4UJbo71jVrgy/ulyRkZVw/R WL1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=WReAeCmcujyRlEw8VFjfi6jnCagOpRVKxlDLiVwHDMM=; b=OFsKhdypBmk2Q9p2ybbToTQCxZpeRdFFG3N1jUpykFLpKLUga+JjtsMsMEsWFva7Ka 6XLDhMxbIfWoh+HuABdXwuD4IWcTiBx8FMN2WtA/cWkAn9ES25BXK0kVrk0F4TrCIjNk 0T8onaLA/Ty+xM8w/zk6HCceGieSSohSX4xpTS/4rb0dgxh9sTSDZws2SrCCjkUxiDiW NrW+W0LFtB5/oslo6nQ+Rmvd9wRIDzXkMenlGq61GpQ2N9CiIiYB34wgYEUEWrIHETrS YRZ/jfERyfORu3b6LZ1yiI8VWqreAudSV+QD3daWW4kTEe8BdZF2b7Libhkp1uBqQbxw If9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=mf+IZ0KK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id yd23si19258867ejb.466.2021.08.24.09.35.40; Tue, 24 Aug 2021 09:36:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=mf+IZ0KK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229715AbhHXQe6 (ORCPT + 99 others); Tue, 24 Aug 2021 12:34:58 -0400 Received: from mail.skyhub.de ([5.9.137.197]:44530 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229569AbhHXQe5 (ORCPT ); Tue, 24 Aug 2021 12:34:57 -0400 Received: from zn.tnic (p200300ec2f11440049ee8a07127e6a59.dip0.t-ipconnect.de [IPv6:2003:ec:2f11:4400:49ee:8a07:127e:6a59]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 4ED8E1EC04D1; Tue, 24 Aug 2021 18:34:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1629822848; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=WReAeCmcujyRlEw8VFjfi6jnCagOpRVKxlDLiVwHDMM=; b=mf+IZ0KKzN2z+PLAy3yChJBq0W4PY+SuYPl7vp5+3lLKHOPGN/W4fVJD71FpY1Uc9KkawU 27LbgZ+GcI+rbK2cUQmIqf/IftIrYIqJj3zvC2BSEMUG2C7qqtIoiKKpMpqvGLYVw+S3c9 BJ3VRMy0Q3KlKt8vvvaTCh2Q2VkDzHc= Date: Tue, 24 Aug 2021 18:34:45 +0200 From: Borislav Petkov To: Kuppuswamy Sathyanarayanan Cc: Thomas Gleixner , Ingo Molnar , Peter Zijlstra , Andy Lutomirski , Peter H Anvin , Dave Hansen , Tony Luck , Dan Williams , Andi Kleen , Kirill Shutemov , Sean Christopherson , Kuppuswamy Sathyanarayanan , x86@kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v5 09/12] x86/tdx: Wire up KVM hypercalls Message-ID: References: <20210804181329.2899708-1-sathyanarayanan.kuppuswamy@linux.intel.com> <20210804181329.2899708-10-sathyanarayanan.kuppuswamy@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20210804181329.2899708-10-sathyanarayanan.kuppuswamy@linux.intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 04, 2021 at 11:13:26AM -0700, Kuppuswamy Sathyanarayanan wrote: > From: "Kirill A. Shutemov" > > KVM hypercalls use the "vmcall" or "vmmcall" instructions. Write instruction mnemonics in all caps pls. > +# This option enables KVM specific hypercalls in TDX guest. > +config INTEL_TDX_GUEST_KVM What is that config option really for? IOW, can't you use CONFIG_KVM_GUEST instead? > + def_bool y > + depends on KVM_GUEST && INTEL_TDX_GUEST > + > endif #HYPERVISOR_GUEST > > source "arch/x86/Kconfig.cpu" > diff --git a/arch/x86/include/asm/asm-prototypes.h b/arch/x86/include/asm/asm-prototypes.h > index 4cb726c71ed8..9855a9ff2924 100644 > --- a/arch/x86/include/asm/asm-prototypes.h > +++ b/arch/x86/include/asm/asm-prototypes.h > @@ -17,6 +17,10 @@ > extern void cmpxchg8b_emu(void); > #endif > > +#ifdef CONFIG_INTEL_TDX_GUEST > +#include > +#endif What "ASM sysmbol generation issue" forced this? ... > diff --git a/arch/x86/include/asm/tdx.h b/arch/x86/include/asm/tdx.h > index 846fe58f0426..8fa33e2c98db 100644 > --- a/arch/x86/include/asm/tdx.h > +++ b/arch/x86/include/asm/tdx.h > @@ -6,8 +6,9 @@ > #include > #include > > -#define TDX_CPUID_LEAF_ID 0x21 > -#define TDX_HYPERCALL_STANDARD 0 > +#define TDX_CPUID_LEAF_ID 0x21 > +#define TDX_HYPERCALL_STANDARD 0 > +#define TDX_HYPERCALL_VENDOR_KVM 0x4d564b2e584454 "TDX.KVM" Yeah, you can put it in a comment so that people don't have to do the CTRL-V game in vim insert mode, i.e., ":help i_CTRL-V_digit" :-) > /* > * Used in __tdx_module_call() helper function to gather the > @@ -80,4 +81,29 @@ static inline bool tdx_prot_guest_has(unsigned long flag) { return false; } > > #endif /* CONFIG_INTEL_TDX_GUEST */ > > +#ifdef CONFIG_INTEL_TDX_GUEST_KVM I don't think that even needs the ifdeffery. If it is not used, the inline will simply get discarded so why bother? > + > +static inline long tdx_kvm_hypercall(unsigned int nr, unsigned long p1, > + unsigned long p2, unsigned long p3, > + unsigned long p4) > +{ > + struct tdx_hypercall_output out; > + u64 err; > + > + err = __tdx_hypercall(TDX_HYPERCALL_VENDOR_KVM, nr, p1, p2, > + p3, p4, &out); > + > + BUG_ON(err); > + > + return out.r10; > +} > +#else > +static inline long tdx_kvm_hypercall(unsigned int nr, unsigned long p1, > + unsigned long p2, unsigned long p3, > + unsigned long p4) > +{ > + return -ENODEV; > +} > +#endif /* CONFIG_INTEL_TDX_GUEST_KVM */ > + > #endif /* _ASM_X86_TDX_H */ > diff --git a/arch/x86/kernel/tdcall.S b/arch/x86/kernel/tdcall.S > index 9df94f87465d..1823bac4542d 100644 > --- a/arch/x86/kernel/tdcall.S > +++ b/arch/x86/kernel/tdcall.S > @@ -3,6 +3,7 @@ > #include > #include > #include > +#include > > #include > #include > @@ -309,3 +310,4 @@ skip_sti: > > retq > SYM_FUNC_END(__tdx_hypercall) > +EXPORT_SYMBOL(__tdx_hypercall); EXPORT_SYMBOL_GPL, of course. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette