Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp2939517pxb; Tue, 24 Aug 2021 11:02:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzaMdWvELivmbWerpv8DSKJozh0FtFn1coLnPqmrd2v06ZO5b/yDmc2z51BJNoY1aLjLcO5 X-Received: by 2002:a92:ab0f:: with SMTP id v15mr27285602ilh.286.1629828168964; Tue, 24 Aug 2021 11:02:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629828168; cv=none; d=google.com; s=arc-20160816; b=LTmQjSyYzcuRlV+EUrEpUOE8E3HNgablx2wmgX0/C+BlB8Zf+mKZgG8bKdeP5TNy3o cQSw1Xr7K/kFokG/wwyCKbCKP+wYZai+vVKt+fFB9L8BjpCb+306XKo7M6AesNccnr8I kBrWyFedUI9zPuZhEQNwoAmbjhkQklLwZ+IsQ+Pu98mlm1BtZ4xdbp9Z69zHqTGsAFea RzqMBPBYnfL56raEhNGjuMGMlbWZSuzWShh8ziwb+Gxk72YuoxGWcKQxj7maUSX1HDHE hhUgbdH831Beu73TGSxnIr5mrgM2nUCQcZY/pFXqx//hhQCMXys/Dl7CVLD+dVEWp9sK rFeg== 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=HaBtrWrajmGcfbWLYhDUsIXaLchGb1bstlD6N7edDYs=; b=FNOclASWmpgkWwGLHxiOuUdhldX30nkuVKeUYWuuawoSInZlNiildy9ubKLVnFuudN ChWIpTe6kZKXwO41tEgYfOO/fdN9X8ojlWz1LD3ethXt4hT+tlCoCXcuD+iBU62YAIye rEneOP6bq/PMr59k/6/uRS3k+92TzGD1N+EOJYxSOJdYvITDnoZeVW34sPshtjyvFz34 51ajew1LmPV+CoFFrapVvDNrRs0XyFNF2LOcVuS3a2Jt+Rj+rDs2yXsMSp76d3mmDm48 P2mE6X7U709F6niJScpHlFYbz+OEcvjLx8pqEGvyzXJFCe52Az364mewRGM9D0w6huNa YL9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=g6VPThMZ; 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 z22si17910959jaq.37.2021.08.24.11.02.32; Tue, 24 Aug 2021 11:02:48 -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=g6VPThMZ; 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 S239782AbhHXSCQ (ORCPT + 99 others); Tue, 24 Aug 2021 14:02:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41806 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239149AbhHXSCI (ORCPT ); Tue, 24 Aug 2021 14:02:08 -0400 Received: from mail.skyhub.de (mail.skyhub.de [IPv6:2a01:4f8:190:11c2::b:1457]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2019C061B3C for ; Tue, 24 Aug 2021 10:48:00 -0700 (PDT) Received: from zn.tnic (p200300ec2f114400ce3b938495d443bc.dip0.t-ipconnect.de [IPv6:2003:ec:2f11:4400:ce3b:9384:95d4:43bc]) (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 37E691EC04D1; Tue, 24 Aug 2021 19:47:55 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1629827275; 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=HaBtrWrajmGcfbWLYhDUsIXaLchGb1bstlD6N7edDYs=; b=g6VPThMZAQl+bN5jor6udrLQHslQI+kWjkakwucuN3cXS4VSEBJnQaGykKZw7VXPTuj4Yk sQq2QARrjzij8NZtkXOTwE+XyVBZbJ5DLqaZTd+mDSHj9VaekRNBGNdOerq3Q+Ne5yi1ui FNYhVfDNjhQoDort5l3IUEfHd3xabuo= Date: Tue, 24 Aug 2021 19:48:37 +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 12/12] x86/tdx: Handle CPUID via #VE Message-ID: References: <20210804181329.2899708-1-sathyanarayanan.kuppuswamy@linux.intel.com> <20210804181329.2899708-13-sathyanarayanan.kuppuswamy@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20210804181329.2899708-13-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:29AM -0700, Kuppuswamy Sathyanarayanan wrote: > From: "Kirill A. Shutemov" > > TDX has three classes of CPUID leaves: some CPUID leaves > are always handled by the CPU, others are handled by the TDX module, > and some others are handled by the VMM. Since the VMM cannot directly > intercept the instruction these are reflected with a #VE exception > to the guest, which then converts it into a hypercall to the VMM, > or handled directly. > > The TDX module EAS has a full list of CPUID leaves which are handled EAS? > natively or by the TDX module in 16.2. Only unknown CPUIDs are handled by 16.2? I believe that commit message was forgotten to be converted to outside-Intel speak. Please do so. > the #VE method. In practice this typically only applies to the > hypervisor specific CPUIDs unknown to the native CPU. hypervisor-specific > Therefore there is no risk of causing this in early CPUID code which > runs before the #VE handler is set up because it will never access > those exotic CPUID leaves. > > Signed-off-by: Kirill A. Shutemov > Reviewed-by: Andi Kleen > Reviewed-by: Tony Luck > Signed-off-by: Kuppuswamy Sathyanarayanan > --- > > Changes since v4: > * None > > Changes since v3: > * None > > arch/x86/kernel/tdx.c | 18 ++++++++++++++++++ > 1 file changed, 18 insertions(+) > > diff --git a/arch/x86/kernel/tdx.c b/arch/x86/kernel/tdx.c > index d16c7f8759ea..5d2fd6c8b01c 100644 > --- a/arch/x86/kernel/tdx.c > +++ b/arch/x86/kernel/tdx.c > @@ -153,6 +153,21 @@ static int tdg_write_msr_safe(unsigned int msr, unsigned int low, > return ret ? -EIO : 0; > } > > +static void tdg_handle_cpuid(struct pt_regs *regs) > +{ > + u64 ret; > + struct tdx_hypercall_output out = {0}; > + > + ret = _tdx_hypercall(EXIT_REASON_CPUID, regs->ax, regs->cx, 0, 0, &out); > + > + WARN_ON(ret); Why warn and not forward the error, instead, so that it lands in ve_raise_fault() ? -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette