Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp3115646pxb; Fri, 4 Feb 2022 01:28:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJwEq1t860hPi/iGWlSvVseEHYK5rtDdlH+/r2KBG6TKOXLBfgXMFy1RvIguyUKDO1D3POvK X-Received: by 2002:a17:907:8a1b:: with SMTP id sc27mr1744363ejc.300.1643966887012; Fri, 04 Feb 2022 01:28:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643966887; cv=none; d=google.com; s=arc-20160816; b=NjhjjBRVQKUh1oGOIGaCoKUOGgI0n3Wuonu9cC99ITv3sbqqsPsmP5mG58ZZJJuwWB JeNI6of+wPiVxBnjyBoPGD8sxImwI704TeeWY4xlKrpq6eEP0aYUYGfA7pj34W7zEelZ DYsOr66uk3a/iIGsPRUNijzoH9jKJk2BFJR5P8O/i8d5slkLs8jnwF2YEuhxW42Twdwr XRWl/p6/6+hGoaetBtt6Aey5alv9fqozCujY0tLAei25E5/KpsJMPqjKFgBjnnA3pyUd p07qp7+ZdmqueRR2akQsiF3NyAXlRhtCOIXS48X4PMgVpjR34zSaOOSPfrdl8oX1agMF 90PQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=jcHaf3e/6oiN1KcirjfqMmosPqy3ruXHMgDwkzeKAZQ=; b=sJAwXEwsh+z9YR2OfPJ+3TP9tjo/TVDYvl3oyE2dOXG87VyuU0AOKlEH9JRN2grbcB bQAexppv0MyAB3ADwiGxA1gXiRfYS/9F5wV85E2gG1HuHBWLC+uH96vYzsQLQievTMTE jOpPFFilOMNg3LpKlW+P8Fm66Gpt+HsRcyTosB6dY/8aqpGtT/xFsr+6drE0yhJc9eBw IkPCCqTXMcAY0VLFzMd+pptl4dBt2ycWqX6IFXk7Wi5mBLb9qFsB+0oQqiYm8z8+lNKF A3In0mzvQQzZF8UMYxtAyA+o/wcjw9/euCwLGDAaJSxoVHjHaqq4ZAUd7hvHEJaWQvUq TfLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=H7zLdTKd; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g15si875502eds.333.2022.02.04.01.27.40; Fri, 04 Feb 2022 01:28:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=H7zLdTKd; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234340AbiBAVjh (ORCPT + 99 others); Tue, 1 Feb 2022 16:39:37 -0500 Received: from Galois.linutronix.de ([193.142.43.55]:41988 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232965AbiBAVjh (ORCPT ); Tue, 1 Feb 2022 16:39:37 -0500 From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1643751576; 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: in-reply-to:in-reply-to:references:references; bh=jcHaf3e/6oiN1KcirjfqMmosPqy3ruXHMgDwkzeKAZQ=; b=H7zLdTKdeI1edCC5U0hN+tUz+JROOtfgspgeUL+peO4efjz2oiXaeLskyQUgYG5RRlf8g6 EVyknW6ICLVSJ2oh03rRN0gLY04eNrUSCqUOpPUlj8d6HG3TS90SHziEvVyLw1uthgmG9m O+AswFbh0Y9PK/TGkPc3wg/+YZHqudNRskbHoy1Nu29MVdz6H4MnLR8NJaYlKt2vfcbS5k 07LDf+T2YQjaopJqYCS8XxsO85WKyrQmwK9XtBbrf4SiTVcbHu3328pnxz1baaHSeWmjpB irV3SMAoC3G+IjEUuYYc+8lRp+SlQXApRIcemITVRNq3blZGjyPiIif94pgZKw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1643751576; 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: in-reply-to:in-reply-to:references:references; bh=jcHaf3e/6oiN1KcirjfqMmosPqy3ruXHMgDwkzeKAZQ=; b=Uf9hijGOx+1w8I62Exu2JJy88jsMMaGH5MOfbgHwPSIhVDrd4JtRrX1GtS0e7zP42Uw1dO 9VgsXNun7OBhtgCA== To: "Kirill A. Shutemov" , mingo@redhat.com, bp@alien8.de, dave.hansen@intel.com, luto@kernel.org, peterz@infradead.org Cc: sathyanarayanan.kuppuswamy@linux.intel.com, aarcange@redhat.com, ak@linux.intel.com, dan.j.williams@intel.com, david@redhat.com, hpa@zytor.com, jgross@suse.com, jmattson@google.com, joro@8bytes.org, jpoimboe@redhat.com, knsathya@kernel.org, pbonzini@redhat.com, sdeep@vmware.com, seanjc@google.com, tony.luck@intel.com, vkuznets@redhat.com, wanpengli@tencent.com, x86@kernel.org, linux-kernel@vger.kernel.org, "Kirill A. Shutemov" Subject: Re: [PATCHv2 07/29] x86/tdx: Handle CPUID via #VE In-Reply-To: <20220124150215.36893-8-kirill.shutemov@linux.intel.com> References: <20220124150215.36893-1-kirill.shutemov@linux.intel.com> <20220124150215.36893-8-kirill.shutemov@linux.intel.com> Date: Tue, 01 Feb 2022 22:39:35 +0100 Message-ID: <87y22uxo4o.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 24 2022 at 18:01, Kirill A. Shutemov wrote: > +static bool tdx_handle_cpuid(struct pt_regs *regs) > +{ > + struct tdx_hypercall_output out; > + > + /* > + * Emulate the CPUID instruction via a hypercall. More info about > + * ABI can be found in TDX Guest-Host-Communication Interface > + * (GHCI), section titled "VP.VMCALL". > + */ > + if (_tdx_hypercall(EXIT_REASON_CPUID, regs->ax, regs->cx, 0, 0, &out)) > + return false; > + > + /* > + * As per TDX GHCI CPUID ABI, r12-r15 registers contain contents of > + * EAX, EBX, ECX, EDX registers after the CPUID instruction execution. > + * So copy the register contents back to pt_regs. > + */ > + regs->ax = out.r12; > + regs->bx = out.r13; > + regs->cx = out.r14; > + regs->dx = out.r15; > + > + return true; > +} Ack. > bool tdx_get_ve_info(struct ve_info *ve) > { > struct tdx_module_output out; > @@ -157,8 +182,18 @@ bool tdx_get_ve_info(struct ve_info *ve) > */ > static bool tdx_virt_exception_user(struct pt_regs *regs, struct ve_info *ve) > { > - pr_warn("Unexpected #VE: %lld\n", ve->exit_reason); > - return false; > + bool ret = false; > + > + switch (ve->exit_reason) { > + case EXIT_REASON_CPUID: > + ret = tdx_handle_cpuid(regs); > + break; Comment about ret and break applies accordingly. Thanks, tglx