Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp169775pxt; Wed, 4 Aug 2021 19:11:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxTYiCLVO1KTxUderupUym0ojWFGXXU6zs76cPcxNFUEMYRdXCeXhjXn+69kQ7tYrKPRfvz X-Received: by 2002:a17:906:c342:: with SMTP id ci2mr2267546ejb.122.1628129508033; Wed, 04 Aug 2021 19:11:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628129508; cv=none; d=google.com; s=arc-20160816; b=JLmpduD/GMma0ZRDWhUofURApu043rVeK88oQ3yGhFTvZUVI/IuXgtXDwejIql8/WS b2OED4mtjE9gaVQNzbFNEn3+p9YLNgdqA8//sSnIsusrofKvS+8SQqyVCoKo21B0muwS LzXvzyDsPcsD5SN1ZElq74doNLXH19Eizx14kT1kv2hzECvayHKviNbHec2ZQDOTzjL2 vm6Xsr1c28QchrJNkFWCaqvSkl7OJLE1n5ZYbluxUupvfg3FSCFGu6H4HYBrWRc0fZpp yiUN7W4cGLwedjvAzctd5LUPZlC2SHy38Xurn3b1aFsSaN8hCoOdF1aVGhcVNmC68iv6 fYHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=qNTAakDsYDdWsHQEyZ/rgEiGSsqlmIOET8+P8lLhUqk=; b=EclGqLeoWRdBkyhzgrt+3rFAprINWzmzlq56HclA93Ewook0xT4dvuQTzVl1FsG+Ab eWyTUJdruL5BmhRXmXk4w6wFFo0im9Z82Rdu7XlzkWjDowwYGFMY/zZPj7Wbb9/iOnB3 F0dfXB8eKXneFEUaLsMS29LYxGt71l5AEcjOZRopjyNfMTlh1WMfSXi8QT/ayXlDNomX v5Mdz3uBATC6k7QdrTOcGsp9+R02L7x5cqiorSDYhnYEAu0kZnrhV3CCKPyajUboVaBE TbObUvvvQgfba3F42oFlZ9czqJd1r+a/qm/nv9rS+2RPzBk5ijFkf0sFe7qKWOJdXhvX 0K1Q== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gg8si4098518ejb.531.2021.08.04.19.11.25; Wed, 04 Aug 2021 19:11: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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238926AbhHDVD0 (ORCPT + 99 others); Wed, 4 Aug 2021 17:03:26 -0400 Received: from mga01.intel.com ([192.55.52.88]:50993 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231771AbhHDVDT (ORCPT ); Wed, 4 Aug 2021 17:03:19 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10066"; a="235972196" X-IronPort-AV: E=Sophos;i="5.84,295,1620716400"; d="scan'208";a="235972196" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Aug 2021 14:03:05 -0700 X-IronPort-AV: E=Sophos;i="5.84,295,1620716400"; d="scan'208";a="512230737" Received: from bguvendi-mobl.amr.corp.intel.com (HELO skuppusw-mobl5.amr.corp.intel.com) ([10.212.99.93]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Aug 2021 14:03:05 -0700 Subject: Re: [PATCH v5 11/12] x86/tdx: Don't write CSTAR MSR on Intel To: Sean Christopherson Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Peter Zijlstra , Andy Lutomirski , Peter H Anvin , Dave Hansen , Tony Luck , Dan Williams , Andi Kleen , Kirill Shutemov , Kuppuswamy Sathyanarayanan , x86@kernel.org, linux-kernel@vger.kernel.org References: <20210804181329.2899708-1-sathyanarayanan.kuppuswamy@linux.intel.com> <20210804181329.2899708-12-sathyanarayanan.kuppuswamy@linux.intel.com> From: "Kuppuswamy, Sathyanarayanan" Message-ID: <4c1ee7b9-9941-fdc4-73f5-3d2ef0530556@linux.intel.com> Date: Wed, 4 Aug 2021 14:03:03 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 8/4/21 11:31 AM, Sean Christopherson wrote: >> On Intel CPUs writing the CSTAR MSR is not really needed. Syscalls >> from 32bit work using SYSENTER and 32bit SYSCALL is an illegal opcode. >> But the kernel did write it anyways even though it was ignored by >> the CPU. Inside a TDX guest this actually leads to a #GP. While the #GP >> is caught and recovered from, it prints an ugly message at boot. >> Do not write the CSTAR MSR on Intel CPUs. > Not that it really matters, but... > > Is #GP the actual TDX-Module behavior? If so, isn't that a contradiction with No, #GP is triggered by guest. > respect to the TDX-Module architecture? It says: > > guest TD access violations to MSRs can cause a #GP(0) in most cases where the > MSR is enumerated as inaccessible by the Intel TDX module via CPUID > virtualization. In other cases, guest TD access violations to MSRs can cause > a #VE. > > Given that there is no dedicated CPUID flag for CSTAR and CSTAR obviously exists > on Intel CPUs, I don't see how the TDX-Module can possible enumerate CSTAR as > being inaccessible. > > Regardless of #GP versus #VE, "Table 16.2 MSR Virtualization" needs to state the > actual behavior. Even in this case, it will trigger #VE. But since CSTAR MSR is not supported, write to it will fail and leads to #VE fault. File: arch/x86/kernel/traps.c 1183 DEFINE_IDTENTRY(exc_virtualization_exception) 1201 if (!ret) 1202 ret = tdg_handle_virtualization_exception(regs, &ve); 1203 /* 1204 * If tdg_handle_virtualization_exception() could not process 1205 * it successfully, treat it as #GP(0) and handle it. 1206 */ 1207 if (ret) 1208 ve_raise_fault(regs, 0); -- Sathyanarayanan Kuppuswamy Linux Kernel Developer