linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Borislav Petkov <bp@alien8.de>
To: Kuppuswamy Sathyanarayanan  <sathyanarayanan.kuppuswamy@linux.intel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>,
	x86@kernel.org, Paolo Bonzini <pbonzini@redhat.com>,
	Juergen Gross <jgross@suse.com>, Deep Shah <sdeep@vmware.com>,
	VMware Inc <pv-drivers@vmware.com>,
	Vitaly Kuznetsov <vkuznets@redhat.com>,
	Wanpeng Li <wanpengli@tencent.com>,
	Jim Mattson <jmattson@google.com>, Joerg Roedel <joro@8bytes.org>,
	Peter H Anvin <hpa@zytor.com>,
	Dave Hansen <dave.hansen@intel.com>,
	Tony Luck <tony.luck@intel.com>,
	Dan Williams <dan.j.williams@intel.com>,
	Andi Kleen <ak@linux.intel.com>,
	Kirill Shutemov <kirill.shutemov@linux.intel.com>,
	Sean Christopherson <seanjc@google.com>,
	Kuppuswamy Sathyanarayanan <knsathya@kernel.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v7 01/12] x86/tdx: Add Intel ARCH support to cc_platform_has()
Date: Tue, 28 Sep 2021 13:11:33 +0200	[thread overview]
Message-ID: <YVL4ZUGhfsh1QfRX@zn.tnic> (raw)
In-Reply-To: <YUTI5Vy/fLT/q/Lh@zn.tnic>

On Fri, Sep 17, 2021 at 06:57:09PM +0200, Borislav Petkov wrote:
> diff --git a/arch/x86/kernel/cc_platform.c b/arch/x86/kernel/cc_platform.c
> index b43bacdc40da..6037201c8437 100644
> --- a/arch/x86/kernel/cc_platform.c
> +++ b/arch/x86/kernel/cc_platform.c
> @@ -18,6 +18,8 @@ bool cc_platform_has(enum cc_attr attr)
>  	if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD ||
>  	    boot_cpu_data.x86_vendor == X86_VENDOR_HYGON)
>  		return amd_cc_platform_has(attr);
> +	else if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL)
		 ^^^^^^^^^^^^^

Hmm, ok, so this won't work. I did:

---
diff --git a/arch/x86/kernel/cc_platform.c b/arch/x86/kernel/cc_platform.c
index 03bb2f343ddb..9024a9f58603 100644
--- a/arch/x86/kernel/cc_platform.c
+++ b/arch/x86/kernel/cc_platform.c
@@ -64,6 +64,8 @@ bool cc_platform_has(enum cc_attr attr)
 	if (sme_me_mask)
 		return amd_cc_platform_has(attr);
 
+	WARN_ON_ONCE(!boot_cpu_data.initialized);
+
 	return false;
 }
 EXPORT_SYMBOL_GPL(cc_platform_has);

---

ontop of the latest version:

https://git.kernel.org/pub/scm/linux/kernel/git/bp/bp.git/log/?h=rc3-cc

and it fires, see below.

So I'm thinking you should use cpuid_has_tdx_guest() instead but cache
its result so that you don't call CPUID each time the kernel executes
cc_platform_has().

This way there won't be any false positives.

Thx.

early console in setup code
[    0.000000] ------------[ cut here ]------------
[    0.000000] WARNING: CPU: 0 PID: 0 at arch/x86/kernel/cc_platform.c:67 cc_platform_has+0x4c/0x60
[    0.000000] Modules linked in:
[    0.000000] CPU: 0 PID: 0 Comm: swapper Not tainted 5.15.0-rc3+ #3
[    0.000000] RIP: 0010:cc_platform_has+0x4c/0x60
[    0.000000] Code: 85 ff b8 01 00 00 00 74 24 48 8b 05 2e 8e 1d 01 48 f7 d0 83 e0 01 c3 83 ff 03 75 13 48 8b 05 1b 8e 1d 01 48 d1 e8 83 e0 01 c3 <0f> 0b c3 f3 c3 31 c0 c3 48 8b 05 05 8e 1d 01 83 e0 01 c3 cc e8 8b
[    0.000000] RSP: 0000:ffffffff82203f20 EFLAGS: 00010046 ORIG_RAX: 0000000000000000
[    0.000000] RAX: 0000000000000000 RBX: ffff888000013950 RCX: 0000000000000000
[    0.000000] RDX: 00000000ffffffff RSI: 0000000000000000 RDI: 0000000000000001
[    0.000000] RBP: ffff888000013950 R08: 0000ffffffffffff R09: ffff0000ffffffff
[    0.000000] R10: ffffffff0000ffff R11: 00000000000001f0 R12: 0000000000000000
[    0.000000] R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
[    0.000000] FS:  0000000000000000(0000) GS:ffffffff89624000(0000) knlGS:0000000000000000
[    0.000000] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[    0.000000] CR2: 0000000000000000 CR3: 00000000096a4000 CR4: 00000000000000a0
[    0.000000] Call Trace:
[    0.000000]  <TASK>
[    0.000000]  ? sme_map_bootdata+0xe/0x57
[    0.000000]  ? copy_bootdata+0x9/0x5a
[    0.000000]  ? x86_64_start_kernel+0x57/0x73
[    0.000000]  ? secondary_startup_64_no_verify+0xb0/0xbb
[    0.000000]  </TASK>
[    0.000000] random: get_random_bytes called from __warn+0xc2/0x140 with crng_init=0
[    0.000000] ---[ end trace 0000000000000000 ]---


-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette

  reply	other threads:[~2021-09-28 11:11 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-16 18:35 [PATCH v7 00/12] Add TDX Guest Support (Initial support) Kuppuswamy Sathyanarayanan
2021-09-16 18:35 ` [PATCH v7 01/12] x86/tdx: Add Intel ARCH support to cc_platform_has() Kuppuswamy Sathyanarayanan
2021-09-16 18:44   ` Dave Hansen
2021-09-16 19:06     ` Borislav Petkov
2021-09-16 19:57       ` Dave Hansen
2021-09-17 16:57   ` Borislav Petkov
2021-09-28 11:11     ` Borislav Petkov [this message]
2021-09-16 18:35 ` [PATCH v7 02/12] x86/paravirt: Move halt paravirt calls under CONFIG_PARAVIRT Kuppuswamy Sathyanarayanan
2021-09-16 18:35 ` [PATCH v7 03/12] x86/tdx: Introduce INTEL_TDX_GUEST config option Kuppuswamy Sathyanarayanan
2021-09-16 18:35 ` [PATCH v7 04/12] x86/cpufeatures: Add TDX Guest CPU feature Kuppuswamy Sathyanarayanan
2021-09-23 10:02   ` Borislav Petkov
2021-09-23 14:10     ` Kuppuswamy, Sathyanarayanan
2021-09-23 14:16       ` Borislav Petkov
2021-09-23 14:20         ` Kuppuswamy, Sathyanarayanan
2021-09-16 18:35 ` [PATCH v7 05/12] x86/tdx: Add TDX guest support to intel_cc_platform_has() Kuppuswamy Sathyanarayanan
2021-09-23 10:36   ` Borislav Petkov
2021-09-23 14:10     ` Kuppuswamy, Sathyanarayanan
2021-09-16 18:35 ` [PATCH v7 06/12] x86/tdx: Add __tdx_module_call() and __tdx_hypercall() helper functions Kuppuswamy Sathyanarayanan
2021-09-16 18:35 ` [PATCH v7 07/12] x86/traps: Add #VE support for TDX guest Kuppuswamy Sathyanarayanan
2021-09-16 18:35 ` [PATCH v7 08/12] x86/tdx: Add HLT " Kuppuswamy Sathyanarayanan
2021-09-23 18:09   ` Borislav Petkov
2021-09-23 19:33     ` Kuppuswamy, Sathyanarayanan
2021-09-24 20:00       ` Kuppuswamy, Sathyanarayanan
2021-09-16 18:35 ` [PATCH v7 09/12] x86/tdx: Wire up KVM hypercalls Kuppuswamy Sathyanarayanan
2021-09-16 18:35 ` [PATCH v7 10/12] x86/tdx: Add MSR support for TDX guest Kuppuswamy Sathyanarayanan
2021-09-16 18:35 ` [PATCH v7 11/12] x86/tdx: Don't write CSTAR MSR on Intel Kuppuswamy Sathyanarayanan
2021-09-16 18:35 ` [PATCH v7 12/12] x86/tdx: Handle CPUID via #VE Kuppuswamy Sathyanarayanan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YVL4ZUGhfsh1QfRX@zn.tnic \
    --to=bp@alien8.de \
    --cc=ak@linux.intel.com \
    --cc=dan.j.williams@intel.com \
    --cc=dave.hansen@intel.com \
    --cc=hpa@zytor.com \
    --cc=jgross@suse.com \
    --cc=jmattson@google.com \
    --cc=joro@8bytes.org \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=knsathya@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=pv-drivers@vmware.com \
    --cc=sathyanarayanan.kuppuswamy@linux.intel.com \
    --cc=sdeep@vmware.com \
    --cc=seanjc@google.com \
    --cc=tglx@linutronix.de \
    --cc=tony.luck@intel.com \
    --cc=vkuznets@redhat.com \
    --cc=wanpengli@tencent.com \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).