Message ID | 20221214194056.161492-49-michael.roth@amd.com (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id DEB58C4332F for <linux-mm@archiver.kernel.org>; Wed, 14 Dec 2022 20:01:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 80D508E0009; Wed, 14 Dec 2022 15:01:54 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7E46D8E0002; Wed, 14 Dec 2022 15:01:54 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 685C58E0009; Wed, 14 Dec 2022 15:01:54 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 585498E0002 for <linux-mm@kvack.org>; Wed, 14 Dec 2022 15:01:54 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 0BF75160F4D for <linux-mm@kvack.org>; Wed, 14 Dec 2022 20:01:54 +0000 (UTC) X-FDA: 80241982548.14.37CCE50 Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2043.outbound.protection.outlook.com [40.107.101.43]) by imf04.hostedemail.com (Postfix) with ESMTP id 0B5A140023 for <linux-mm@kvack.org>; Wed, 14 Dec 2022 20:01:50 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=gwC+03GN; spf=pass (imf04.hostedemail.com: domain of Michael.Roth@amd.com designates 40.107.101.43 as permitted sender) smtp.mailfrom=Michael.Roth@amd.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=pass (policy=quarantine) header.from=amd.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1671048111; h=from:from:sender: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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=9kFUIUAb0hyW9i3i+pIzOyi+dQb0DpLo0gJKM8xz7HE=; b=5t3Jssnib4i0NVxHuMXJDw2Bw9RgyL2ExNtVRrHD0eEVqA92ac4FHS3701ptOKSCSXQbkc GeBUGbgPqDbwwvyl8AszcYjyskzacFpVL65qtwV5hTHVEF2fAM04Lwv2ltcRga/2w65Osa 8PaBSTg1hGOiOoziD6Lo5i7jqWf5D/s= ARC-Authentication-Results: i=2; imf04.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=gwC+03GN; spf=pass (imf04.hostedemail.com: domain of Michael.Roth@amd.com designates 40.107.101.43 as permitted sender) smtp.mailfrom=Michael.Roth@amd.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=pass (policy=quarantine) header.from=amd.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1671048111; a=rsa-sha256; cv=pass; b=kfw4UA+idCqZDMAYVIUa/KidlhysRAix7S/HCYkVrpvnAL4xIUfm5G2YXjsTlKqxpaR/Zp AMAy0G6sMGHG+jOBQNNZ16X3LJmfoL49w439bqNUp7elEdGsXQpkiteChQ6VKuQNwENnOO w9f4Cw2x6+STdhwU8ns0XTu4bEPYFZQ= ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=H9tShW/mbNybmPxfm6mLgcjWi41B1iMGwE67JibC7sn6nqJ5rJKC33d44BWRhCQFKsjVPGs/PF1+NrBd9oGkuza3LIL4djo76Edoaa5CpJSc+z0dVdnycbrU0ZcjpmPe2lZOxK+lXpLlaZRrTvyl0UsRZ//0jqxZdoiN58oCRXrRjmPvG4NJQKevBxowAk1liWknbocv0+HcOnAIbINVGDvB4Y9+HOzQKuiDLSvNINZFppipEXiXiGz51xez5YTwp4Dj8IiZdsUHgLVKlNA9N5C5QBDyLSIl3puMIG3NJ1/2IhQ/8X1jVGyKMU9QOWjQA/d41Sck7kwPNZXb03dsJQ== 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=9kFUIUAb0hyW9i3i+pIzOyi+dQb0DpLo0gJKM8xz7HE=; b=O5QbqDM+MOzIWMbsUfFFFjjVqykGwEk1sX9p30oP0n0qgOE+B9FhNsNdFf0LTQ++gUiG9HirNHWuJTP/RpytJBs2eInEe3OUeAuw8RxnVLoR+SnR9poKr5p8ircjSHnTb8XNlY5Se7f3PfzXWapqmghOU7P1R0f3GE83EAffMen7R7OsZ0kZhAzTkfMvTOe7APvhsjw5oH5dFB9iLeu/SsPTv5iF2a7eycp0WJYkUu88zQqhh1evYSWpYOQeGCYF+wRVDLK3bfwLfaTQGf7dLx7fSvCRvUWZ/qAG3lDMbQV3hxQ7NwXGI4vK6stXer3yghXR4Vhv3fnne/VXsxwrVw== 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=9kFUIUAb0hyW9i3i+pIzOyi+dQb0DpLo0gJKM8xz7HE=; b=gwC+03GNXitbim1DNmZ6+6VIvEUIuoOhKdt6/xKosp42ppJSBUVWD6wzpVzkjtiH3jxCECcVAaF0O+avISsaig1ZgOty6Rrt6rIPRjpJZGYeKyjE1amtbxctaDCxdS4byJ/wRseYWWuMkuv4kNzqLmTgQZIJ8HpPzLkyRxq6UIc= Received: from DM6PR18CA0017.namprd18.prod.outlook.com (2603:10b6:5:15b::30) by DS0PR12MB8199.namprd12.prod.outlook.com (2603:10b6:8:de::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.19; Wed, 14 Dec 2022 20:01:47 +0000 Received: from CY4PEPF0000C96F.namprd02.prod.outlook.com (2603:10b6:5:15b:cafe::79) by DM6PR18CA0017.outlook.office365.com (2603:10b6:5:15b::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.11 via Frontend Transport; Wed, 14 Dec 2022 20:01:47 +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 CY4PEPF0000C96F.mail.protection.outlook.com (10.167.242.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5924.8 via Frontend Transport; Wed, 14 Dec 2022 20:01:47 +0000 Received: from localhost (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.2375.34; Wed, 14 Dec 2022 14:01:46 -0600 From: Michael Roth <michael.roth@amd.com> To: <kvm@vger.kernel.org> CC: <linux-coco@lists.linux.dev>, <linux-mm@kvack.org>, <linux-crypto@vger.kernel.org>, <x86@kernel.org>, <linux-kernel@vger.kernel.org>, <tglx@linutronix.de>, <mingo@redhat.com>, <jroedel@suse.de>, <thomas.lendacky@amd.com>, <hpa@zytor.com>, <ardb@kernel.org>, <pbonzini@redhat.com>, <seanjc@google.com>, <vkuznets@redhat.com>, <wanpengli@tencent.com>, <jmattson@google.com>, <luto@kernel.org>, <dave.hansen@linux.intel.com>, <slp@redhat.com>, <pgonda@google.com>, <peterz@infradead.org>, <srinivas.pandruvada@linux.intel.com>, <rientjes@google.com>, <dovmurik@linux.ibm.com>, <tobin@ibm.com>, <bp@alien8.de>, <vbabka@suse.cz>, <kirill@shutemov.name>, <ak@linux.intel.com>, <tony.luck@intel.com>, <marcorr@google.com>, <sathyanarayanan.kuppuswamy@linux.intel.com>, <alpergun@google.com>, <dgilbert@redhat.com>, <jarkko@kernel.org>, <ashish.kalra@amd.com>, <harald@profian.com>, Brijesh Singh <brijesh.singh@amd.com> Subject: [PATCH RFC v7 48/64] KVM: SVM: Add support to handle Page State Change VMGEXIT Date: Wed, 14 Dec 2022 13:40:40 -0600 Message-ID: <20221214194056.161492-49-michael.roth@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221214194056.161492-1-michael.roth@amd.com> References: <20221214194056.161492-1-michael.roth@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain 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: CY4PEPF0000C96F:EE_|DS0PR12MB8199:EE_ X-MS-Office365-Filtering-Correlation-Id: ed048386-2c81-4f8b-3cf3-08dade0e0866 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Y1keZEAKZfOkN9afkJYpKHOnOz+AMze9tGVi52NefP4qJ1V3nX+h8oEnhwfjdqTy3lHvWofSG8O5M5hjMVJoakEQSLuIHXVsfi2pclsbo+XLQ9POexkv/wo1EEOkbw3XU6Ukl40SMzsrw1HKfSIR8HZdA+dsnFObTmTP+W5+QdmR1F3CciVy+aeJu2wai+hTWXuMkJY4vWfEz6VXARPHOaf7EnjCc1LxBuJDssongzU5cNHPR44IZHqCrFFstj/vK3kqINP+wc9+QbQhkks1krL0JD2wNrHqALhsQmdD5bF2Av992JhwCxbj8mzZ0yKVdfNRuSoZ3rmsXzNUWEVLvRT/wteRG3tUGYMQV+rffSYiKChXqguXqJHgMgGZ8HPgDz17xl5Nyv+iiL60SXhRJY1hCnwPWdFjO2FkofAsuFpF9edEb1SRzUff/lxd1NS0xz6lfpjoC/fdCDepmKbScz0dX1drRQcVQrzPK22ySCRyqzOmQu4RE17MdfGoZCvMbg2IMEjiFhJgCQ96RybCiv2KvoNQZHohk98RVW7lvq6Tf4XpuM9xH3xh67buwMVlSGUqYKJdahRuig3uDXdrKJOx7GjFnSK5HjQn9dNGGrngkJ3UlhOdgxtBGqF2/09PdcRmUVHEAEVPBHF58z+RAAI43YGiuS/hyJ4XP/xz3ftURKcVShSAeXR0udkIutXB6x3cdjJYlXxzaWbOjKaRfkwSjWcN+zE1wrs24WqV7MQ= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:CA;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(39860400002)(376002)(346002)(396003)(136003)(451199015)(46966006)(36840700001)(40470700004)(356005)(7406005)(82740400003)(2906002)(81166007)(7416002)(36860700001)(5660300002)(86362001)(44832011)(478600001)(41300700001)(40460700003)(40480700001)(6666004)(70586007)(4326008)(8676002)(26005)(83380400001)(426003)(82310400005)(186003)(8936002)(47076005)(16526019)(316002)(1076003)(2616005)(70206006)(54906003)(66899015)(336012)(6916009)(36756003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Dec 2022 20:01:47.7078 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ed048386-2c81-4f8b-3cf3-08dade0e0866 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: CY4PEPF0000C96F.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB8199 X-Stat-Signature: 9exhjzktoi91qqramjcojw9n4r7is5gh X-Rspam-User: X-Rspamd-Queue-Id: 0B5A140023 X-Rspamd-Server: rspam06 X-HE-Tag: 1671048110-539467 X-HE-Meta: U2FsdGVkX1+MPgEw9ecXXlXM6EP9z5tDt5DhNBR/72jgUZByEOVFdZVPE8qZuG86pIx34JVtexAHCoNyVu1aTXXDnQFCd2jrFNR9Qd1sN8PAO/1ce2OtLt9sMI9IFU+Z9BsOVUPtK9+uN6j4TZy22jfG3Mi4BNWj7eHSo0raT0LyjqmeT1/Bm5sg4SK9qOemFfW8DqR4vWJJO0wmWd/O0PXDLKX0gJqL6nD3MfApvnUtxpr0igKBSvuAblsz6QFvU5fXd0CqwQ7BdcbMMP5G+csSbhxYgxdkR0rBRkagbKK1GST8SuMVqNbHH42cbXqkoF1PK8138sR/lN0STlq7o8gCK5gTdtqVnN1kX2+s4oVHRFJ0hFj+aE/w7qlwMdibbi48b4ydFtCxLIk0GFb3jm9b8W7dA9kg+hvMndyouqZoF8LHUAK+3w9HGZ0x/yPSuVTbgnXDrLIevOtXvOAWsa/LusdnQZ3HphvVViK+bBO4r22ut11912MjCKxYlSpTo+zYLSkPfDTaUlAelAVdkyap+ZG/i9vXRFO5AkuK0X1tCngVNRAEN+w+ryLPKkEgNe9dhII+giDd29qFPn/D2OUCWVfOGDZcJIMRE6tu0akdMX9ckTgMc1pcTVnrz12Bl5dErsDfi72pRMsQ9MGigGXf1Lt5sfVSeCsQ9xUqLpqw/C3B4toW15U7PKr3U+Uc2qJXLKabGuAVtUzeLJdM+3jbU86fGwzCjjtLdrOEFTJ6VMeagGj35T4gpBa6Y5UEcmZbA9cJeA2LLXQbooG44iGVRuBOUq6hTBWpdRo6ZRAzAjyKL55q+ieTvDStovgRXU+BAEsaEtsmhEFsJVY++hFyN+urrSHhcX7ghP+h+YQyru0PP9DP0OZJxv8EtcaDKhfi7XTE1KXC7zM/mLr+Qrw4P10uZOz6CT5sG6MAOGBIv6/ixzG0atzGtlqRPLbzGIWKHUe0w0cx65gzo1l IRI0PBmr shbrK X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: <linux-mm.kvack.org> |
Series |
Add AMD Secure Nested Paging (SEV-SNP) Hypervisor Support
|
expand
|
diff --git a/arch/x86/include/asm/sev-common.h b/arch/x86/include/asm/sev-common.h index ee38f7408470..1b111cde8c82 100644 --- a/arch/x86/include/asm/sev-common.h +++ b/arch/x86/include/asm/sev-common.h @@ -130,6 +130,13 @@ enum psc_op { /* SNP Page State Change NAE event */ #define VMGEXIT_PSC_MAX_ENTRY 253 +/* The page state change hdr structure in not valid */ +#define PSC_INVALID_HDR 1 +/* The hdr.cur_entry or hdr.end_entry is not valid */ +#define PSC_INVALID_ENTRY 2 +/* Page state change encountered undefined error */ +#define PSC_UNDEF_ERR 3 + struct psc_hdr { u16 cur_entry; u16 end_entry; diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c index d7988629073b..abe6444bf5d4 100644 --- a/arch/x86/kvm/svm/sev.c +++ b/arch/x86/kvm/svm/sev.c @@ -3164,6 +3164,7 @@ static int sev_es_validate_vmgexit(struct vcpu_svm *svm, u64 *exit_code) case SVM_VMGEXIT_AP_JUMP_TABLE: case SVM_VMGEXIT_UNSUPPORTED_EVENT: case SVM_VMGEXIT_HV_FEATURES: + case SVM_VMGEXIT_PSC: break; default: reason = GHCB_ERR_INVALID_EVENT; @@ -3368,6 +3369,17 @@ static int snp_complete_psc_msr_protocol(struct kvm_vcpu *vcpu) return 1; /* resume */ } +/* + * TODO: need to process the GHCB contents and report the proper error code + * instead of assuming success. + */ +static int snp_complete_psc(struct kvm_vcpu *vcpu) +{ + svm_set_ghcb_sw_exit_info_2(vcpu, 0); + + return 1; +} + static int sev_handle_vmgexit_msr_protocol(struct vcpu_svm *svm) { struct vmcb_control_area *control = &svm->vmcb->control; @@ -3595,6 +3607,12 @@ int sev_handle_vmgexit(struct kvm_vcpu *vcpu) ret = 1; break; } + case SVM_VMGEXIT_PSC: + /* Let userspace handling allocating/deallocating backing pages. */ + vcpu->run->exit_reason = KVM_EXIT_VMGEXIT; + vcpu->run->vmgexit.ghcb_msr = ghcb_gpa; + vcpu->arch.complete_userspace_io = snp_complete_psc; + break; case SVM_VMGEXIT_UNSUPPORTED_EVENT: vcpu_unimpl(vcpu, "vmgexit: unsupported event - exit_info_1=%#llx, exit_info_2=%#llx\n",