Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp398491pxb; Fri, 28 Jan 2022 01:24:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJwZg01XPCyv8rsQwKzn8e/uTAiPWMY4RQFJPMG0a18Q+ZhBhUFZnV21Tg0+g2oL8TETK7Yy X-Received: by 2002:a17:907:6da6:: with SMTP id sb38mr6358537ejc.58.1643361877857; Fri, 28 Jan 2022 01:24:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643361877; cv=none; d=google.com; s=arc-20160816; b=P0d0sDYsbYw84e/V6n0aqvIHAdNtpvL/UouHsZkUihJJJwzxCMjgRTVUeTWteFwY2f hcF1bRZS3Tnc5AkvrMRhWeiEFuf7EabWBkrCYFwhz9R3+vOG9wkas5s0fu8LTvC0Qlnd fzJOe4Uw4WWuG6t+NaDsrE429jAS4ERiktqeJG/7Sa7ftZ0x1KdanrPNBDqmwUReezB+ P49d+9SzPSt9zhnSVHKxz4csjGxMbhizRGaJpHkylcLErmq7EuORNiTcKNcw5wpyADoi QccOvMnv3shOysYs9wkEwmhXbRuzHe0DK7t2KqiDpjLpvV/IvrB7l2M1LeXp/8HvgSZF 9Kxw== 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=JV2DpgJLMt5fK61b8cQw16AJuA9Yd0fzMbdEJ84O1bI=; b=vkOJMjU7/Tz354lSAXeklevIiiw5KebYHQvpvgGvz2ad4EUzRisWkvK/3sR0US2y5M hQvj+LBmrifVfnpNX5Yfi7zFl7/JNMHudthfvidyi/C2CF523q0HetMqfH4/B39+epRC BSkskK5tI1B9uZtmsBudPKjoDQdfBc0nByuOdaRB6WLHuGcejcGpSfVrIiEFuHDHh8X2 0j8FngGRN70ohT3IG2k2x+nNn3J89+eiopozwwIkZsiCo2jh2csoAh3+7AVH8qTetR43 q3zPJwhDgR0QeroUWjKdmLQbf+/LiBaSWw6vHgj4MQIY5mkSTEJmp71CmvLdMFLnWarN /otQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=DYVY3w3M; 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 f14si2635379ejj.869.2022.01.28.01.24.13; Fri, 28 Jan 2022 01:24:37 -0800 (PST) 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=DYVY3w3M; 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 S243596AbiA0QVR (ORCPT + 99 others); Thu, 27 Jan 2022 11:21:17 -0500 Received: from mail.skyhub.de ([5.9.137.197]:49234 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238119AbiA0QVQ (ORCPT ); Thu, 27 Jan 2022 11:21:16 -0500 Received: from zn.tnic (dslb-088-067-221-104.088.067.pools.vodafone-ip.de [88.67.221.104]) (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 5F39D1EC051E; Thu, 27 Jan 2022 17:21:10 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1643300470; 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=JV2DpgJLMt5fK61b8cQw16AJuA9Yd0fzMbdEJ84O1bI=; b=DYVY3w3MlRb/vS+Uoa0UNXjOHvdGQJvfENWZIgRm9CKBGmOIsZB/aUtz6WnHSEiS1BzdPL ZXRMTdQ6KSQIEWzu3DIxLtPvR/68xS1elZsq0cP/EF6jlpKI1Z1Zt5ku4IdgdFMhD8HRbv /OGEY01w0PdI/APwHhVGffqHITSR6Rc= Date: Thu, 27 Jan 2022 17:21:06 +0100 From: Borislav Petkov To: Brijesh Singh Cc: x86@kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-efi@vger.kernel.org, platform-driver-x86@vger.kernel.org, linux-coco@lists.linux.dev, linux-mm@kvack.org, Thomas Gleixner , Ingo Molnar , Joerg Roedel , Tom Lendacky , "H. Peter Anvin" , Ard Biesheuvel , Paolo Bonzini , Sean Christopherson , Vitaly Kuznetsov , Jim Mattson , Andy Lutomirski , Dave Hansen , Sergio Lopez , Peter Gonda , Peter Zijlstra , Srinivas Pandruvada , David Rientjes , Dov Murik , Tobin Feldman-Fitzthum , Michael Roth , Vlastimil Babka , "Kirill A . Shutemov" , Andi Kleen , "Dr . David Alan Gilbert" , tony.luck@intel.com, marcorr@google.com, sathyanarayanan.kuppuswamy@linux.intel.com Subject: Re: [PATCH v8 36/40] x86/sev: Provide support for SNP guest request NAEs Message-ID: References: <20211210154332.11526-1-brijesh.singh@amd.com> <20211210154332.11526-37-brijesh.singh@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20211210154332.11526-37-brijesh.singh@amd.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Dec 10, 2021 at 09:43:28AM -0600, Brijesh Singh wrote: > Version 2 of GHCB specification provides SNP_GUEST_REQUEST and > SNP_EXT_GUEST_REQUEST NAE that can be used by the SNP guest to communicate > with the PSP. > > While at it, add a snp_issue_guest_request() helper that can be used by Not "that can" but "that will". > driver or other subsystem to issue the request to PSP. > > See SEV-SNP and GHCB spec for more details. > > Signed-off-by: Brijesh Singh > --- > arch/x86/include/asm/sev-common.h | 3 ++ > arch/x86/include/asm/sev.h | 14 +++++++++ > arch/x86/include/uapi/asm/svm.h | 4 +++ > arch/x86/kernel/sev.c | 51 +++++++++++++++++++++++++++++++ > 4 files changed, 72 insertions(+) > > diff --git a/arch/x86/include/asm/sev-common.h b/arch/x86/include/asm/sev-common.h > index 673e6778194b..346600724b84 100644 > --- a/arch/x86/include/asm/sev-common.h > +++ b/arch/x86/include/asm/sev-common.h > @@ -128,6 +128,9 @@ struct snp_psc_desc { > struct psc_entry entries[VMGEXIT_PSC_MAX_ENTRY]; > } __packed; > > +/* Guest message request error code */ > +#define SNP_GUEST_REQ_INVALID_LEN BIT_ULL(32) SZ_4G is more descriptive, perhaps... > +int snp_issue_guest_request(u64 exit_code, struct snp_req_data *input, unsigned long *fw_err) > +{ > + struct ghcb_state state; > + unsigned long flags; > + struct ghcb *ghcb; > + int ret; > + > + if (!cc_platform_has(CC_ATTR_SEV_SNP)) > + return -ENODEV; > + > + /* __sev_get_ghcb() need to run with IRQs disabled because it using per-cpu GHCB */ needs it is using a > + local_irq_save(flags); > + > + ghcb = __sev_get_ghcb(&state); > + if (!ghcb) { > + ret = -EIO; > + goto e_restore_irq; > + } > + > + vc_ghcb_invalidate(ghcb); > + > + if (exit_code == SVM_VMGEXIT_EXT_GUEST_REQUEST) { > + ghcb_set_rax(ghcb, input->data_gpa); > + ghcb_set_rbx(ghcb, input->data_npages); > + } > + > + ret = sev_es_ghcb_hv_call(ghcb, true, NULL, exit_code, input->req_gpa, input->resp_gpa); ^^^^^ That's ctxt which is accessed without a NULL check in verify_exception_info(). Why aren't you allocating a ctxt on stack like the other callers do? -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette