Message ID | 20231016115028.996656-7-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 73281CDB465 for <linux-mm@archiver.kernel.org>; Mon, 16 Oct 2023 11:53:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 14B4D8D006A; Mon, 16 Oct 2023 07:53:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0FBCA8D0001; Mon, 16 Oct 2023 07:53:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EDF258D006A; Mon, 16 Oct 2023 07:53:53 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id DD5868D0001 for <linux-mm@kvack.org>; Mon, 16 Oct 2023 07:53:53 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 6DD1F1A0943 for <linux-mm@kvack.org>; Mon, 16 Oct 2023 11:53:53 +0000 (UTC) X-FDA: 81351165546.22.AA4D7AE Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2080.outbound.protection.outlook.com [40.107.93.80]) by imf13.hostedemail.com (Postfix) with ESMTP id 6B6B02001D for <linux-mm@kvack.org>; Mon, 16 Oct 2023 11:53:50 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=0eQBvdbE; dmarc=pass (policy=quarantine) header.from=amd.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf13.hostedemail.com: domain of Michael.Roth@amd.com designates 40.107.93.80 as permitted sender) smtp.mailfrom=Michael.Roth@amd.com ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1697457230; 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=/OHgKUYFAZCONnATUVnBIwfZqzs8EaYMPwtwwWj6zPA=; b=jsJ69pNWskkADYh+5rrrxRzoT4jivhfYJ2r2P/tMgz9wdYkk1GUm+F9Ll68c0Z1REEX4/s w3ZW4ojyzY0rAsbmd0u+L5XZyO+4mcCUzFRQdW62MG4IMYMhaZ209k4HAuIo5wOfXpcH+Z csDslGi7WMfmGUSd+Iq+cYojFMBF0m4= ARC-Authentication-Results: i=2; imf13.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=0eQBvdbE; dmarc=pass (policy=quarantine) header.from=amd.com; arc=pass ("microsoft.com:s=arcselector9901:i=1"); spf=pass (imf13.hostedemail.com: domain of Michael.Roth@amd.com designates 40.107.93.80 as permitted sender) smtp.mailfrom=Michael.Roth@amd.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1697457230; a=rsa-sha256; cv=pass; b=gUtY/RJEzQnwtiErrDUAWy1PHdIkDu/IaMTZ6yTG7Ga6FJYb7qUGrbv96gNufw38xpp7Zr KofWdF71mu+QQVFjKP+eIJneKDtojDICmRbL9G/R+OoEPmtaMax1XrIymvec5YRMsdTg9T 3YHyKznxbfqPfK7jjJWfslfIGVkFdKk= ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=n5CN1ZxpI+MrfKf75ATvqxNc3pBVZKPqEV0k47JRlguNoeL0f4HhR9Qk/Dr1xvC9EitCSfdv7psb4h0OXgLPLFGvL5pBA6mgn/YGbKs1okPDor2CoxVw0IV6YWrgWiaZ+T8lzeouH6pyvpBOo5XMjALLp7aNAh3HkU9xUkLwTBNMK7FjAz/kH09F8zUyGXWPCoDu3zgJYP/tJw3M7AES+eGrOYVgwogV8xCkFhuYn6JQlHLizpvQYldF+n/KWxMIwFJ3eyasd2NiGYVM/6L4yJQ4QCCMwbTh3nrxK9hADJCQCmYxT6NrCnVSefuIhZLlUW/fW4XjBKWE2NHadP4L+A== 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=/OHgKUYFAZCONnATUVnBIwfZqzs8EaYMPwtwwWj6zPA=; b=Nv9XKqQrEI8C0pYLOaLvJMDsJA2dJulq/iZ9a8stITQykhTtWkJATUvA28UXno1EAwdhuGQ7z8LSUwJ2eU46SuBIguU1yglfRYQE2reh7dVj/dmzMfaukzM6QWDPoKT8gN9A9cf01teLd2i5ZxaYPNK+xTuLNqty5KftxktsG4LyUtMpEVpHm6bMp03bk5UfQoo4oHi6D+sGaTcta8pHSfmCy8/D/wHaGLHL1pTLt5UWEcby+maA4IKP8t9/6/R9z0GxZ2MCYznjzbqpXPWRhbBt1sCi4lttCRcbdiUaeTXTKsH2QMjAiOdrprETByHBk3kpIQQfHgeEuTh5i6bVOQ== 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=/OHgKUYFAZCONnATUVnBIwfZqzs8EaYMPwtwwWj6zPA=; b=0eQBvdbEtgJNh4G0P1QDKsH9akDx+vqB2rT0NUSb0Tw71a0yNWIPJdHkK8xUlwCMJLtIzLseJKvxelamt1MTc+YMVYcOmcLQFKjz8tswpHHRSOBqJ5S6hDHsuYFtbQLK/cVibkGzmLz5cE/bPbGSZdexjn4PeBu89Uh3Ufm3Hg4= Received: from SN6PR04CA0095.namprd04.prod.outlook.com (2603:10b6:805:f2::36) by CY8PR12MB7660.namprd12.prod.outlook.com (2603:10b6:930:84::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.34; Mon, 16 Oct 2023 11:53:48 +0000 Received: from SA2PEPF000015C8.namprd03.prod.outlook.com (2603:10b6:805:f2:cafe::da) by SN6PR04CA0095.outlook.office365.com (2603:10b6:805:f2::36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.35 via Frontend Transport; Mon, 16 Oct 2023 11:53:48 +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 SA2PEPF000015C8.mail.protection.outlook.com (10.167.241.198) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6838.22 via Frontend Transport; Mon, 16 Oct 2023 11:53:48 +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.2507.27; Mon, 16 Oct 2023 06:53:47 -0500 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>, <linux-fsdevel@vger.kernel.org>, <pbonzini@redhat.com>, <seanjc@google.com>, <isaku.yamahata@intel.com>, <ackerleytng@google.com>, <vbabka@suse.cz>, <ashish.kalra@amd.com>, <nikunj.dadhania@amd.com>, <jroedel@suse.de>, <pankaj.gupta@amd.com> Subject: [PATCH RFC gmem v1 6/8] KVM: x86: Add KVM_X86_SNP_VM vm_type Date: Mon, 16 Oct 2023 06:50:26 -0500 Message-ID: <20231016115028.996656-7-michael.roth@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231016115028.996656-1-michael.roth@amd.com> References: <20231016115028.996656-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: SA2PEPF000015C8:EE_|CY8PR12MB7660:EE_ X-MS-Office365-Filtering-Correlation-Id: 3db7f415-47f2-4d5c-f397-08dbce3e8eb8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: j+OqCqSbLp/+f5t5QRtCPHeQtMatZSancDPNeZu1R3eqdDR5vxNvR3hEGhgmLTU2hJviSfx7RiLAm/klSI3W2aoEZCrI3dSgjV/koKuepCwa6YLRRjYsU2T16+Qgu+3WzLLP9wVxlZZBQDc6pLxCO4dQ+Hu+YH1j+ofKnrdokizvx3Y40OnRqXmXh6/6/UW36GRWYXY9M0LMoKCDZZE8gEzunw+LBQa2dCWZWGlaIeY6YRwhF+7IMIHaZiMzJVciDB6Hz+kZYZhiDjFJJiUjZi0YYMvFiWtS+py/8MdtSt3spGHcpUHm8EBUc8gzbf1SrIt6cYpMwrEPrrcvuuJTTTmj2a9lMSa/4XtAsrXpmOaJH44i3Deps4E092OTOwc7wrf8i8H8eo78my3/nmSYqYi3BwimCysaVsBzOMya4B9ulogS5I+xrSKDW4DUhXk2SvUNq6ykbq3UOjoPztFyHG0gcmcs+JiXDYGxuPSPCMXpIZmd2g0QYfxb7aoG8qOikVQuRMo5gex2rbqSUis5uTkfgnmvrBoofubOclWE3VdnezIrGmFig0O65edHe7Gvs9vRkwpD1H5P5UFzQSPH/p3ob03CxkakC+OAWmU0LzmTchsXKijIJOrF99iejpHIaOjhjZiS8x3+pYQGWJrtu0I8r6c8agLYi6yNAoA//j6fcMDoCJtTVwy4WNPibvHCF5a8/bFIC5KBMzn7eUcW3QkbDJjEugmTT2T/g6+eYHYsui+Z7ZFklB8ihVFe96gpFuXW1gSx/u4d1P+Ilcw3Fw== 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)(396003)(136003)(39860400002)(346002)(376002)(230922051799003)(64100799003)(451199024)(1800799009)(186009)(82310400011)(36840700001)(40470700004)(46966006)(40480700001)(40460700003)(6666004)(478600001)(36860700001)(47076005)(86362001)(36756003)(81166007)(356005)(82740400003)(2906002)(7416002)(83380400001)(16526019)(426003)(336012)(26005)(2616005)(1076003)(70586007)(5660300002)(41300700001)(6916009)(54906003)(8936002)(4326008)(8676002)(316002)(44832011)(70206006)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2023 11:53:48.0055 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3db7f415-47f2-4d5c-f397-08dbce3e8eb8 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: SA2PEPF000015C8.namprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB7660 X-Rspam-User: X-Stat-Signature: b16j9i1uhzeucxrforznowd8sxf6931b X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 6B6B02001D X-HE-Tag: 1697457230-479078 X-HE-Meta: U2FsdGVkX1/fDAXCjiO9gdOTBjKhWBk4e0qhIdKKzkKSubfho5gow3s4UUR/R8F1LlV7LCSN5Aq/HPDIx9k/jshrH0i9uqH/sDBLLv42aacX7PRH3v5S7EANg5/ZRtPU9lxbptyrG5C26zyxH2hMTzzVZKrNm7EMmpMdZcOe++RHmU/+keFJidV21nDAPbUfjweNECksh3FZl1/pGNKMdJVvAL3+XPtzfNXgOpy4vQ6/CAU54LQRFBv6pjhqmG726uc9D8Py+ZpC0Z2PG3Ijo2xuTWCRy+aZxSeG8iaV9Yqx7dNi6EpWba9tkQ2p8Am1Hqsn0Au6wDPUxKAw+7+m1LdWZKL0cpeIjAtkCtMTyFhp4ceHuwSkkLVRm+nuKBnSmXj3Dmv2attaaBRHxLDpeaSoOAaDwJ0KcfcRsBV5+Rkd63HKFVqCP5hGHuVeJ4gX0VtRZYDo4Dek6faLhwfKnzwN1llmnxSdf2cT4I8Xtn3yGnFYVnYmNJywP8NaWmNXa7H7qITl2sH1jv2z95wkjnp2HnXntw1kQcLo5afHk9S86Uv3/KF3YwvthRjVpGdnToaDPjpsWeKTA5+a4GUutshfiEs6jeT2yQnNKJFGcDHWqcCvxfuXrrf1m0/TJ0UQGwZJCHp6JXPLw2f605JkW70rKv3HKG3CcFXi22P7Hu8gqcwjN1iYAlizMz7nSDIqWnEI2/5R5tz6maX6QnHv4vpyTGXnmxcnNMr/qfdGw1WCw3Z+udvIl1tMbJvqvEtv1lVHlR6ABcv3ui3PQ9X46S/OzES9EVJKXdxQPP5ZZAXRsf19J5iJCDFXyfHFpViurtLkDn1doERoqszceDn75m5x4VyRuK7m/MaN7oX6KWb+Oylv0RTNeCMZrau2oXgz+VBg3EwWpuWyndz4GhKlTk+c3UmPodebfKuGxLQahVyFa0mJKiV+xkdql16oZdkpj1ttFSHHxCvNsmpD8Oo uEIYkB54 bvhuqdhL4k3GmXSfBFy9+LiwOYjh7U1u68vXQuVsfhwcSvZ+azFgjevYpP79uagN701cQSHACl87Z+LPd1AmkFDayV77LCkv9EVOoAif+DFjyKmmQvYMlgG2SC+SN9j9ID5jUNmhkGHivqTUiNL+n6DxOCfr0iXrj6EsZkYqo/FzqK8Ev9uZkb8lcgUDKtXYjYm+K0SGqw/9/kwF0vt254UFwySQYiPGj3zfsq+N9bmaKNsi+i+/LuKVtCSHswiW9c/XnKgawMWASY3/0kuE/QQZtp29d1kTHemGGJdiD13Z7BXg2PukLxj9WNKYQ9HxK8hVIfCyj/n6ZAfsXkYNplBW2/f1ZjK+HcvctWZZshi3EbhVQdenmmn7Hg+qwLfIOlvnW 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 |
KVM: gmem hooks/changes needed for x86 (other archs?)
|
expand
|
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index dbec74783f48..cdc235277a6f 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -2089,6 +2089,8 @@ void kvm_configure_mmu(bool enable_tdp, int tdp_forced_root_level, #define kvm_arch_has_private_mem(kvm) false #endif +bool kvm_is_vm_type(struct kvm *kvm, unsigned long type); + static inline u16 kvm_read_ldt(void) { u16 ldt; diff --git a/arch/x86/include/uapi/asm/kvm.h b/arch/x86/include/uapi/asm/kvm.h index a448d0964fc0..57e4ba484aa2 100644 --- a/arch/x86/include/uapi/asm/kvm.h +++ b/arch/x86/include/uapi/asm/kvm.h @@ -564,5 +564,6 @@ struct kvm_pmu_event_filter { #define KVM_X86_DEFAULT_VM 0 #define KVM_X86_SW_PROTECTED_VM 1 +#define KVM_X86_SNP_VM 3 #endif /* _ASM_X86_KVM_H */ diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 0e95c3a95e59..12f9e99c7ad0 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -4444,10 +4444,16 @@ static int kvm_ioctl_get_supported_hv_cpuid(struct kvm_vcpu *vcpu, static bool kvm_is_vm_type_supported(unsigned long type) { return type == KVM_X86_DEFAULT_VM || - (type == KVM_X86_SW_PROTECTED_VM && + ((type == KVM_X86_SW_PROTECTED_VM || + type == KVM_X86_SNP_VM) && IS_ENABLED(CONFIG_KVM_SW_PROTECTED_VM) && tdp_enabled); } +bool kvm_is_vm_type(struct kvm *kvm, unsigned long type) +{ + return kvm->arch.vm_type == type; +} + int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext) { int r = 0;
In some cases, such as detecting whether a page fault should be handled as a private fault or not, KVM will need to handle things differently versus the existing KVM_X86_PROTECTED_VM type. Add a new KVM_X86_SNP_VM to allow for this, along with a helper to query the vm_type. Signed-off-by: Michael Roth <michael.roth@amd.com> --- arch/x86/include/asm/kvm_host.h | 2 ++ arch/x86/include/uapi/asm/kvm.h | 1 + arch/x86/kvm/x86.c | 8 +++++++- 3 files changed, 10 insertions(+), 1 deletion(-)