Message ID | 166734513630.7716.12952231613533508782.tip-bot2@tip-bot2 |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp3278069wru; Tue, 1 Nov 2022 16:43:31 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5hj7hrjWOpFytLmT3WeCe3DiSSL4mp4OFg3CQgHZekI8o4oO8LwH1ZJiyFBJjpkpXVxlNZ X-Received: by 2002:a63:1058:0:b0:44f:a1cb:7eec with SMTP id 24-20020a631058000000b0044fa1cb7eecmr19709322pgq.117.1667346210635; Tue, 01 Nov 2022 16:43:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667346210; cv=none; d=google.com; s=arc-20160816; b=smHl2K/DeEmrMcxgA6ou4e/rLTjaTi4cGUSpe053nQi3zl0TUb+t7dkrD28yUlZocx NQ5Og7j79z2a0eRd9Rl44yUsws5LSMDY3r2aHfHNDS7HBpE6vfVZXFP4uEt5p/8N2mM/ YaDlx8IBq3iuzWnqo/vR175/NKU5qeLlJmLW0qQlfkDPC3g8rrV2tRIGLDTa3FcFFXBX tUDmxghNpRX+0aRKAVSQV2PngEGunSTg48URmX06vtdskLbaoyZk6fnByMR0IP1cLrWW f3veLvGikIq3la9TCRJ6c+nYGh+SLi2UFTZj8l/HSzHabXoxJUBAZuqejzkn+2RMTaI0 W0EA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:cc:subject:to:reply-to:sender:from :dkim-signature:dkim-signature:date; bh=I0y+lhuQmGVn5FfJdmSsSqet8+hYCRLEMYJ6mzf+imk=; b=LYQ6RFj5rDjcC1Pw+0fDEqrq6fwUCb0RZ6ETkhU9Gj0mEp9eUYRnPdev/uHNbCdmVA AaYufbnjM/pti244shkDgMRfmmfrZ3vU0x76M5Xp56Xo9k4vGdO1X6nTiLVpuf8PL1eH HDvKeXzlMfgkmFmqapM9cZCquIX7XWnD4lSfPSdhMyeFMLaFZCTjxl3ZXQthmuTBguWq xgWxfJ1T8VQzrCSO6j3v6wLbcryx8X7yBqxLV/FgDe8PLjkFJLPQdIFgR2h+VilVsmJz TkHARI+gBw70DnqkBBrNUgba15aK8R6I+8yEnVJG3PTwMhwNvY/oHUAIQh5HjMsL+Njo 3Cyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=ocwjHhsq; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h22-20020a056a001a5600b00565d7dea8bbsi15619032pfv.160.2022.11.01.16.43.18; Tue, 01 Nov 2022 16:43:30 -0700 (PDT) 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=ocwjHhsq; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 S230397AbiKAXZr (ORCPT <rfc822;kartikey406@gmail.com> + 99 others); Tue, 1 Nov 2022 19:25:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229875AbiKAXZk (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 1 Nov 2022 19:25:40 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2EE11759A; Tue, 1 Nov 2022 16:25:39 -0700 (PDT) Date: Tue, 01 Nov 2022 23:25:36 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1667345137; h=from:from:sender:sender:reply-to: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:content-transfer-encoding; bh=I0y+lhuQmGVn5FfJdmSsSqet8+hYCRLEMYJ6mzf+imk=; b=ocwjHhsqkDMORDxhZRk7e2/M12hs2heP6mVSKrctyjQxsZ1zxm21zL+afOe24/4cLKb7BL JwRT764ss3GCaMTCYFE1YU0sSrDbI9Ff4QfWQIrOX23D8NTvQB58JLnuW8NhvShqvT0BTK 934cLxLRlV/Fe5mDA7gnbcDwYHDWq0N5tHWFy2x+3Srn2Z+2JagyQl6BGNo1LzbaTvxIgb CRbqmUpMZlhYmGu7N0yNFX6yRiaI22X7pJHD7QYQFPnFKiWoxZHM0lKHnjkd7rE4G9K3Rs RfVOb5Q2rmU+ePhgONojqaDkOnHjn9ehtWe8I1VV/KBfSTspyaenlbfnhX0S1A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1667345137; h=from:from:sender:sender:reply-to: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:content-transfer-encoding; bh=I0y+lhuQmGVn5FfJdmSsSqet8+hYCRLEMYJ6mzf+imk=; b=sAlyXw8KeGH4/B1syi7NnNrh0XgPqkOKhhSBREeBagzDNSK1e7AcOAyPnHVzMAihNz6AYU ylP+qPO9LTUvUtCQ== From: "tip-bot2 for Dave Hansen" <tip-bot2@linutronix.de> Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/urgent] x86/tdx: Prepare for using "INFO" call for a second purpose Cc: Dave Hansen <dave.hansen@linux.intel.com>, "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>, stable@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org MIME-Version: 1.0 Message-ID: <166734513630.7716.12952231613533508782.tip-bot2@tip-bot2> Robot-ID: <tip-bot2@linutronix.de> Robot-Unsubscribe: Contact <mailto:tglx@linutronix.de> to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748339220142264086?= X-GMAIL-MSGID: =?utf-8?q?1748339220142264086?= |
Series |
[tip:,x86/urgent] x86/tdx: Prepare for using "INFO" call for a second purpose
|
|
Commit Message
tip-bot2 for Thomas Gleixner
Nov. 1, 2022, 11:25 p.m. UTC
The following commit has been merged into the x86/urgent branch of tip: Commit-ID: a6dd6f39008bb3ef7c73ef0a2acc2a4209555bd8 Gitweb: https://git.kernel.org/tip/a6dd6f39008bb3ef7c73ef0a2acc2a4209555bd8 Author: Dave Hansen <dave.hansen@linux.intel.com> AuthorDate: Fri, 28 Oct 2022 17:12:19 +03:00 Committer: Dave Hansen <dave.hansen@linux.intel.com> CommitterDate: Tue, 01 Nov 2022 10:07:15 -07:00 x86/tdx: Prepare for using "INFO" call for a second purpose The TDG.VP.INFO TDCALL provides the guest with various details about the TDX system that the guest needs to run. Only one field is currently used: 'gpa_width' which tells the guest which PTE bits mark pages shared or private. A second field is now needed: the guest "TD attributes" to tell if virtualization exceptions are configured in a way that can harm the guest. Make the naming and calling convention more generic and discrete from the mask-centric one. Thanks to Sathya for the inspiration here, but there's no code, comments or changelogs left from where he started. Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com> Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Tested-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Cc: stable@vger.kernel.org --- arch/x86/coco/tdx/tdx.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
Comments
On Tue, Nov 01, 2022 at 11:25:36PM -0000, tip-bot2 for Dave Hansen wrote: > @@ -121,7 +121,7 @@ static u64 get_cc_mask(void) > * The highest bit of a guest physical address is the "sharing" bit. > * Set it for shared pages and clear it for private pages. > */ > - return BIT_ULL(gpa_width - 1); > + *cc_mask = BIT_ULL(gpa_width - 1); > } I'm looking at the next patch too and I still don't see what the point is of making it a void? IOW, what's wrong with doing this? --- diff --git a/arch/x86/coco/tdx/tdx.c b/arch/x86/coco/tdx/tdx.c index b8998cf0508a..0421cb7f3b86 100644 --- a/arch/x86/coco/tdx/tdx.c +++ b/arch/x86/coco/tdx/tdx.c @@ -100,11 +100,11 @@ static inline void tdx_module_call(u64 fn, u64 rcx, u64 rdx, u64 r8, u64 r9, panic("TDCALL %lld failed (Buggy TDX module!)\n", fn); } -static void tdx_parse_tdinfo(u64 *cc_mask) +static u64 tdx_parse_tdinfo(void) { struct tdx_module_output out; unsigned int gpa_width; - u64 td_attr; + u64 td_attr, ret; /* * TDINFO TDX module call is used to get the TD execution environment @@ -123,7 +123,7 @@ static void tdx_parse_tdinfo(u64 *cc_mask) * can not meaningfully run without it. */ gpa_width = out.rcx & GENMASK(5, 0); - *cc_mask = BIT_ULL(gpa_width - 1); + ret = BIT_ULL(gpa_width - 1); /* * The kernel can not handle #VE's when accessing normal kernel @@ -133,6 +133,8 @@ static void tdx_parse_tdinfo(u64 *cc_mask) td_attr = out.rdx; if (!(td_attr & ATTR_SEPT_VE_DISABLE)) panic("TD misconfiguration: SEPT_VE_DISABLE attibute must be set.\n"); + + return ret; } /* @@ -769,7 +771,7 @@ void __init tdx_early_init(void) setup_force_cpu_cap(X86_FEATURE_TDX_GUEST); cc_set_vendor(CC_VENDOR_INTEL); - tdx_parse_tdinfo(&cc_mask); + cc_mask = tdx_parse_tdinfo(); cc_set_mask(cc_mask); /*
On 11/6/22 04:45, Borislav Petkov wrote: > On Tue, Nov 01, 2022 at 11:25:36PM -0000, tip-bot2 for Dave Hansen wrote: >> @@ -121,7 +121,7 @@ static u64 get_cc_mask(void) >> * The highest bit of a guest physical address is the "sharing" bit. >> * Set it for shared pages and clear it for private pages. >> */ >> - return BIT_ULL(gpa_width - 1); >> + *cc_mask = BIT_ULL(gpa_width - 1); >> } > I'm looking at the next patch too and I still don't see what the point > is of making it a void? > > IOW, what's wrong with doing this? It's fine for now, except that the naming on this: - tdx_parse_tdinfo(&cc_mask); + cc_mask = tdx_parse_tdinfo(); is a bit funky since tdx_parse_tdinfo() is doing a couple of things and will need to return a second item shortly. But, zero objections if you want to make it that way for now.
On Sun, Nov 06, 2022 at 09:02:27AM -0800, Dave Hansen wrote: > It's fine for now, except that the naming on this: > > - tdx_parse_tdinfo(&cc_mask); > + cc_mask = tdx_parse_tdinfo(); > > is a bit funky since tdx_parse_tdinfo() is doing a couple of things Yeah, that was the next thing that was bothering me. > and will need to return a second item shortly. Well, then rename this one back to get_cc_mask() and have a new function return the second item?
On 11/6/22 11:50, Borislav Petkov wrote: > On Sun, Nov 06, 2022 at 09:02:27AM -0800, Dave Hansen wrote: >> It's fine for now, except that the naming on this: >> >> - tdx_parse_tdinfo(&cc_mask); >> + cc_mask = tdx_parse_tdinfo(); >> >> is a bit funky since tdx_parse_tdinfo() is doing a couple of things > Yeah, that was the next thing that was bothering me. > >> and will need to return a second item shortly. > Well, then rename this one back to get_cc_mask() and have a new function > return the second item? That's doable. It would look something like what I've attached for now. The only downside to this is making two tdx_module_call(TDX_GET_INFO...) calls. That seems a bit wasteful, but it's not the end of the world. It would look something like the attached patch. I kinda like the idea of making one tdx_module_call() and parsing it all in one place. The calls are kinda slow, but two of them versus one isn't going to hurt anybody. The other thing I considered was keeping a temporary 'struct tdx_guest_info' structure or something, filling it one, and parsing it in get_cc_mask() and attribute checking functions. But, that seemed like overkill.
diff --git a/arch/x86/coco/tdx/tdx.c b/arch/x86/coco/tdx/tdx.c index 928dcf7..3fee969 100644 --- a/arch/x86/coco/tdx/tdx.c +++ b/arch/x86/coco/tdx/tdx.c @@ -98,7 +98,7 @@ static inline void tdx_module_call(u64 fn, u64 rcx, u64 rdx, u64 r8, u64 r9, panic("TDCALL %lld failed (Buggy TDX module!)\n", fn); } -static u64 get_cc_mask(void) +static void tdx_parse_tdinfo(u64 *cc_mask) { struct tdx_module_output out; unsigned int gpa_width; @@ -121,7 +121,7 @@ static u64 get_cc_mask(void) * The highest bit of a guest physical address is the "sharing" bit. * Set it for shared pages and clear it for private pages. */ - return BIT_ULL(gpa_width - 1); + *cc_mask = BIT_ULL(gpa_width - 1); } /* @@ -758,7 +758,7 @@ void __init tdx_early_init(void) setup_force_cpu_cap(X86_FEATURE_TDX_GUEST); cc_set_vendor(CC_VENDOR_INTEL); - cc_mask = get_cc_mask(); + tdx_parse_tdinfo(&cc_mask); cc_set_mask(cc_mask); /*