From patchwork Tue Oct 10 20:02:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Allen X-Patchwork-Id: 150932 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp107480vqb; Tue, 10 Oct 2023 13:03:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IETW0MNI7arDeYhqFcKzWgWAqJ7f+w3yfc1RhNxNdGqXeCxmfbLwQY6LiaOWc4F3Ie9MxCh X-Received: by 2002:a17:90a:4143:b0:268:ca63:e412 with SMTP id m3-20020a17090a414300b00268ca63e412mr17041043pjg.4.1696968189405; Tue, 10 Oct 2023 13:03:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1696968189; cv=pass; d=google.com; s=arc-20160816; b=Jwq7MrkFLtxgl1GjSDd/6FJIqYRHhFG/dUJkQ+N3QkYpZRx+9lX5eb70qh3fGrpUbk fhZzbgzlRcFQ40YgcDn+yb4hf0bbDidm4zUMFQTrd2KErUw8rM7/SunKd3iCixa2kl7I y0RItIdN9z691mehfHP2SfCKZImxrB+KJ3AwS47MlitdZhKfxWvuSxpbsoO2+GsGHe4G mXuDlwDvAsQ4huONCHxut7HV23wWCCztsPrI9U6/VIABtbHTS5uxcO/VD0Jp5RXgqG8X 0hEDF1e3Hnf6DTaPnD8yOY8cj8UNFhggG0lxfZoA+suyzpC+MDSylCS63YJUCHireiOY GxyA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=QhMVG40k16QnEOd5TZV+P9T38+kg056v8RcfN3Ut5eU=; fh=YsaQLgy1f3waabOGRB2EBTcbAbdCzDUdwWjn34lJ0cQ=; b=a9CXTkMc6vuA5/TSw1xCWMIncoULhCSkBlINdytG24nBg4Uu6XKyIgG80/CMVeaD1N IiD6g067FGK8wfBczqrS1C9Xewdfb19s1phurXlVKqZtZsGgcBvndBbtgcCpV33zDvuH 5tLhsxU4zNqM2RwBnHpVgEBx/1R5mhhHd91CiLVI6nuSr0oQU8eIlyGtP8Wgdl23+Asa JDz/vPQasNq98iVFCxxsIyjpqx/avrZwcdUOC0YZ0ALNLv2QZKAAtejyoEMzeHia3E4b qkOUYQhEqhvAOyhxHQw5JS29NwLoT20tp+7jJgz65OwPQTCRrzzTmrNtg/ZsvONjCeZi j+NQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=AjKv1jxc; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id r2-20020a170902c60200b001c3ea2bbebcsi11654985plr.322.2023.10.10.13.03.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Oct 2023 13:03:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=AjKv1jxc; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 2762F80D31F1; Tue, 10 Oct 2023 13:03:08 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229734AbjJJUDD (ORCPT + 19 others); Tue, 10 Oct 2023 16:03:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229809AbjJJUDC (ORCPT ); Tue, 10 Oct 2023 16:03:02 -0400 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2054.outbound.protection.outlook.com [40.107.243.54]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79B4A93; Tue, 10 Oct 2023 13:03:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=awK26XF2I0eIup0OdBSIaqUE+r/Yv/WTzOes7p3EurFBJn3f9SQFsHlklsdMcdt+Un0EXf06fP0TRrRtZPrO0cTMDilVU1YSwky3tVRh3Ra6oqaQJkg9ioNOnqrk7YdBRN9/X/EYsvfyb4z17PRM3S4wRUnWAItLI9hbPzBeuchXMOB3/bdUEh2ddTa4VHF7CeHSErfDS3Y1W8OvGu5e0rqqaBgwODnsH+yFlK39IuEFrNsTTUHLml6I0xvRbpjl++AdMCFHLeu566UsrerJwxKSZpecNVjbdWjsHFK3zmYQkw6Jz7/m4pk7HnU2KA5gUj69Ct0Znw4vG3UPC3cQyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=QhMVG40k16QnEOd5TZV+P9T38+kg056v8RcfN3Ut5eU=; b=T7XByjHVlmSfRpcgFzH3LCrsMIfK0BlQPry71W27o9f2e/zIYwpiExDQn2LEQcsqMn4QGFEqm55N/HNImdZzNKmu7vASLBvIHIf4K9E97BWGzruTsh5IRU7HXPqfI7+jfndxXlU8A9poh1weW/ACd1ieEuesqaahDwWnC3pYpzV7LVjW9BXkMacJJ/7vPzQEPCpEwrrLj5oNXPAgkDMTuqXAW0w0sJCI53W2mjJJj+dZrsF0+uZOWRcG4cPA6df52H+4yYUztgmfmhkuvynuOSbKPaVcoPZAIEpuVbfhg1lC3EPCtYUEHXxHjZLcBLB4qBWACwhr6WY2v6O1b6oWVA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QhMVG40k16QnEOd5TZV+P9T38+kg056v8RcfN3Ut5eU=; b=AjKv1jxcHYl/ko0bLwMMiYe0TmkkaPCavdybeh8tNaTuosZCbkoJaPZlDnhkqC5pggeg6Ej6rFq5U+eq4fMdj7slorI1QrcXp9nPOSp/4mhlN7XiUsEyRv4xDHPXvEZeBpZbYqIEOzG7Nv5ezq9+KMxuvUH9K/YP01ANbn8G2Z4= Received: from DM6PR07CA0084.namprd07.prod.outlook.com (2603:10b6:5:337::17) by DM4PR12MB6397.namprd12.prod.outlook.com (2603:10b6:8:b4::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.36; Tue, 10 Oct 2023 20:02:57 +0000 Received: from DS2PEPF0000343F.namprd02.prod.outlook.com (2603:10b6:5:337:cafe::ce) by DM6PR07CA0084.outlook.office365.com (2603:10b6:5:337::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.38 via Frontend Transport; Tue, 10 Oct 2023 20:02:57 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by DS2PEPF0000343F.mail.protection.outlook.com (10.167.18.42) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6838.22 via Frontend Transport; Tue, 10 Oct 2023 20:02:57 +0000 Received: from jallen-jump-host.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Tue, 10 Oct 2023 15:02:54 -0500 From: John Allen To: CC: , , , , , , , , John Allen Subject: [PATCH 1/9] KVM: x86: SVM: Emulate reads and writes to shadow stack MSRs Date: Tue, 10 Oct 2023 20:02:12 +0000 Message-ID: <20231010200220.897953-2-john.allen@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231010200220.897953-1-john.allen@amd.com> References: <20231010200220.897953-1-john.allen@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS2PEPF0000343F:EE_|DM4PR12MB6397:EE_ X-MS-Office365-Filtering-Correlation-Id: f71ba29a-0737-43ba-b501-08dbc9cbe5f3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CismyJklKxIOBoF4AW3SxZLHGggE+w5V9qPuusxoJKagNB/KiqKWAUVzzOqV/F4yJw+kJEmPtXdSd7VF0HI+KYjgbjE17mfuV5GEogOjnKLq7UIhpCtWzSktyawejkfnITGDWmNf3Ogk90/FpDCKEsepHRGIBGPJk03vL/SF62PEGKc2bJUZiECfi9EK6JiThxEYJkNseQ2hra2NohKRdW0xfHC2ITVEPXz8WX00MkDu83tUUjSh3lyKEiAZO2lhZ5JWLAYEiedQfwXJGwbQ8GzRyyo7WeZKSV/gpb21FRSP+bfmMF+2Jkj7bPv9c74DVC3HNeQwQrdrkU/SFwDlguyLGQA4/IfWD0xnIhecgHbCCqGkV8ue4ngCLFzg7he8lIqNR7jBHFidM5QWArycIHAquepn4GErKDrhfYDp8VWNmEnojNrRbJxD0ODfjVaKQSzeHsZdE2Ac1v0XIYMI9cx2RCF+R0deV7YWuS+wYwSPqBUEhVC5ZlIpySVU171o1YQFJ8pTTnFfmnPgiFzdydBNx/T4nd++ETxkSJH12OCPyP1bh64T7z/x8PDTkYsEWpT0TmDMNGqk/O+k01Mm2Q/W2i1N/HBiN5MJz/aUazXLe5xkpZYGx1vAsZvPEAMaVnT9niiMN7Pcsf15GJQ+MsknrCrHOV5vJWLzMtdlkaEIieUqyJzCNK5qAIHLKA5cClbIMyVUNirmSX+hdPRbkMygH7Yy7oUmyL+jvefawsQqvwsPVYhUCxL3rgzNhvRZQAB49QpVtPDXnPgJXbKGcA== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(39860400002)(346002)(136003)(396003)(376002)(230922051799003)(64100799003)(451199024)(1800799009)(82310400011)(186009)(36840700001)(40470700004)(46966006)(83380400001)(16526019)(426003)(26005)(2616005)(81166007)(1076003)(336012)(40460700003)(86362001)(36756003)(82740400003)(40480700001)(356005)(8936002)(6666004)(4326008)(478600001)(44832011)(2906002)(8676002)(5660300002)(47076005)(7696005)(36860700001)(6916009)(41300700001)(70206006)(316002)(70586007)(54906003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Oct 2023 20:02:57.5774 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f71ba29a-0737-43ba-b501-08dbc9cbe5f3 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DS2PEPF0000343F.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6397 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, URIBL_BLOCKED autolearn=no 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: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 10 Oct 2023 13:03:08 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779400116091963503 X-GMAIL-MSGID: 1779400116091963503 Set up interception of shadow stack MSRs. In the event that shadow stack is unsupported on the host or the MSRs are otherwise inaccessible, the interception code will return an error. In certain circumstances such as host initiated MSR reads or writes, the interception code will get or set the requested MSR value. Signed-off-by: John Allen Reviewed-by: Maxim Levitsky --- arch/x86/kvm/svm/svm.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index f283eb47f6ac..6a0d225311bc 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -2859,6 +2859,15 @@ static int svm_get_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info) if (guest_cpuid_is_intel(vcpu)) msr_info->data |= (u64)svm->sysenter_esp_hi << 32; break; + case MSR_IA32_S_CET: + msr_info->data = svm->vmcb->save.s_cet; + break; + case MSR_IA32_INT_SSP_TAB: + msr_info->data = svm->vmcb->save.isst_addr; + break; + case MSR_KVM_SSP: + msr_info->data = svm->vmcb->save.ssp; + break; case MSR_TSC_AUX: msr_info->data = svm->tsc_aux; break; @@ -3085,6 +3094,15 @@ static int svm_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr) svm->vmcb01.ptr->save.sysenter_esp = (u32)data; svm->sysenter_esp_hi = guest_cpuid_is_intel(vcpu) ? (data >> 32) : 0; break; + case MSR_IA32_S_CET: + svm->vmcb->save.s_cet = data; + break; + case MSR_IA32_INT_SSP_TAB: + svm->vmcb->save.isst_addr = data; + break; + case MSR_KVM_SSP: + svm->vmcb->save.ssp = data; + break; case MSR_TSC_AUX: /* * TSC_AUX is usually changed only during boot and never read