From patchwork Wed May 1 08:52:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 13650318 Return-Path: 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 63935C10F1A for ; Wed, 1 May 2024 09:05:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0102E6B00A5; Wed, 1 May 2024 05:05:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F02C16B00A7; Wed, 1 May 2024 05:05:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D7C2A6B00A8; Wed, 1 May 2024 05:05:17 -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 BA1776B00A5 for ; Wed, 1 May 2024 05:05:17 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 6825FA16D2 for ; Wed, 1 May 2024 09:05:17 +0000 (UTC) X-FDA: 82069243074.01.A5F26C1 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2072.outbound.protection.outlook.com [40.107.236.72]) by imf14.hostedemail.com (Postfix) with ESMTP id 97C5F10001B for ; Wed, 1 May 2024 09:05:13 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b="lhc4i/Iy"; spf=pass (imf14.hostedemail.com: domain of Michael.Roth@amd.com designates 40.107.236.72 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=1714554313; 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=RY+enspJL5gaYp4jenQZ4TzSk3E82OmppXhPjsVB6o4=; b=hCY00eTmMr6G8quTsPMplhWSQXYo19Rkoj5BQgMDTFyp3Xj1d1l/tXYq0SQy5WWFeLDhq7 BHIN9/sI8AiMXIobyyRpKPKuQ4e4Dc3xu6PQ8E0NSrtYneHY+45Tz3GfrTUzdpgwylV/zz hYcDHdgGqWdXsXZRETbAHHzBDYuv5/0= ARC-Authentication-Results: i=2; imf14.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b="lhc4i/Iy"; spf=pass (imf14.hostedemail.com: domain of Michael.Roth@amd.com designates 40.107.236.72 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=1714554313; a=rsa-sha256; cv=pass; b=sj4cAWqFu7WED6n+lYziL/PKkjgFCZIGi+8cJtlWir75g1pOizA2AZuGKemyNGZZSpsXCQ sw4WQffecOCEvIZzxzIXQ8N8AqKXq2UBEs4rZvemASh+cN5Be5wy/ZAvprcAhNPKpXTtpf QTYoJ3H/L6ljGczxCYA1lV7lF/m45Mo= ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dGqTL+/a1ei8TmW9zsnae+oZbxhPQcuZvK54/zYj2IXBs5JVU+0C93l0mNyghvF48LiT9dN2DSW+7g1gP7WPSW1n6toAZylUgbDuwENiUYydOOO5eaUo3eCedNYj8dVI8iJMmbuD1qY+xQdhyEUYRMp7zeVRYFl70tnLfFfVkJwr5pdY5XHB2LoEu+4rO0BCxA0V30vFxLRIwFA4NFgid2z5Za4JJbdeFRSzeI0FwhvOotJR/5BswAkWyD99ymJTS1AHDwAqXKWE1ENUOiPs6ReWfnxivufUpW6PMYoB67n56lkCNZbZya/MSAaN0rxOyu7RvPTp7qW0qMQJEpFUZw== 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=RY+enspJL5gaYp4jenQZ4TzSk3E82OmppXhPjsVB6o4=; b=H1viPb2TbQf9vDgtH6KOQ472zmC0rcVYqHJHlefsfDsKX0d0vpziwU7TD2+3OoK4IDafWolVjwuu3f7bGZV4QyKVLkug/c1CdvLvKIAf7w5JW/6/nE8ECPQiOd6Ru+g4xDwqLsaG57YShZor6foAxSrSzpVTjr/MUMWODIYaRiYdNu4rGjw9czxPlNgMoOGMbaaNcdGsRjZaXj2MQVVUPArOzuaCnMqOmaBDrbXJ5nO0H88tmyNyYAJnCD/f0Q2M8D65kfQWRSAKAjmgUS9g9pgQvT6QRn3tGd2WgFtcadHV/wlhqENxlfEAREISfQPmyYnm+eXeg0icM6RmKTG80Q== 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 (0) 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=RY+enspJL5gaYp4jenQZ4TzSk3E82OmppXhPjsVB6o4=; b=lhc4i/Iy930I+1DDrpTX2BWCM2fWLehn2UkBVWL1/+rRetesGWacU9xyGa7PF8IZSrxstyN/miMXc13fqcnZf0ZoFKaWvc+UMK+vqSgRlZLP6vA3aEaTB4KJgyHKyDhMbHSgH2z7e8roEg72+7vkTgi2H4J0iH7SSgqtIuszg3E= Received: from BN8PR12CA0015.namprd12.prod.outlook.com (2603:10b6:408:60::28) by SN7PR12MB8101.namprd12.prod.outlook.com (2603:10b6:806:321::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.34; Wed, 1 May 2024 09:05:11 +0000 Received: from BN2PEPF000044A3.namprd02.prod.outlook.com (2603:10b6:408:60:cafe::90) by BN8PR12CA0015.outlook.office365.com (2603:10b6:408:60::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.28 via Frontend Transport; Wed, 1 May 2024 09:05:11 +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 BN2PEPF000044A3.mail.protection.outlook.com (10.167.243.154) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7544.18 via Frontend Transport; Wed, 1 May 2024 09:05:10 +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.35; Wed, 1 May 2024 04:05:07 -0500 From: Michael Roth To: CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v15 16/20] KVM: SEV: Avoid WBINVD for HVA-based MMU notifications for SNP Date: Wed, 1 May 2024 03:52:06 -0500 Message-ID: <20240501085210.2213060-17-michael.roth@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240501085210.2213060-1-michael.roth@amd.com> References: <20240501085210.2213060-1-michael.roth@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF000044A3:EE_|SN7PR12MB8101:EE_ X-MS-Office365-Filtering-Correlation-Id: 6e60ccb4-a7a6-4f96-35cc-08dc69bdcde7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|82310400014|36860700004|1800799015|376005|7416005; X-Microsoft-Antispam-Message-Info: 7EXutAV9z67jxAWXY+EEe0xFLLyq3DxCCTrXd2Gim0fkdxNG0DkiyHoI30K0XCenP1WOnlZsL9C9OjbZcbmvFGjnrKXCv4bg5tZpXFLukuLFiYx7FEzdfFHleFg3uhfB+ZEZow5mmTOD5QPVFavrzHgrQccpzsm4MU+Ytwv2XiTNeUO1fg59/ZDs/FVFO5KCwj/O/GsrLLGJhdUIvbKxNLg0oKFcSi+ZIyo0evUw9RVUnipaq75/MwM5wLwKIJriVGRhFfcxhhArV4TboRHLpQMa3gJd4uKvcNlXrQ+S5g9lMOCqic1eKsq/NFZVOn/hxaL9XG15mVbpLYIDWCbkJIw2QL38dt4T+9VTLCUHVrUyAa3XL9PwZUBs4SfDHua6yIFwQVljDdjbBdXZqiJQjYHfyMEvtwTTxylMol2xWxdeFPHHh2AFz7InoRxrUzQyjj+HMJzd9B+lK56yF7PVwW03RGjv2iUXIwroXcyZSDupKdzdLeXIOrq8usfYE8o0GQx+pvjU0TYeAQ2qCs8xsp4AvRvWkEVwPGEetIKKXhvdsuaVBSEaKMh8b9azw8ji2qEhVK98WaTkrayTWvK2C0ivf0s7YsGaPAL2ohhZQmxLrPuN6Nt/kPYYwmf7Y010nk5Hy8P64E58TfEljGXWS/eb4yvm3Ol3eaxjYI73wIOPEYKCemOWmXlmLvNcLrKkSWWDy8ZTtDqNuWdqmcbo/Ws381xLQFSmX43dcBFqWDwvvvz8KL/E3yvKjMhBKZoRuoRFEclYOun83xDFDHjIjODGbCYzMBqKw0Is+a0vfTGAdvPsUd1l3GSXXbm83PBEZfpvjsY/hdYE7k25CXExVOt4kep7Nzdszp9AWThZbu2zG6qX8gQth7JUh/psFUfrDSPk9xHorGqco73XF0KH62+0r19dRYhqKAFYlMjocD+Cp2AFi12RkNiGNMtLldAS/N1c6/Oqiq86lgE5N+A92WwYBO0hoph70mS22EDmskMBqWzQpTFJufRrxWfMVBfnd+taxz3HDlMSwT0PgIfIzgn5GF4HeatyOjb3abekS+rYdwprZWaj1btHNm3PKl/6KA3so+Rqdu9tldYjF30SdjJJ8/4m2ng2S3qx5Z/N9TQqg11ioijlC9AgskkM1SAmUFCvd3zNFzc893lnEoob6pQuPtaCpmEyoVXW6GvJkUgiKoWEGKiymObP5z/bkjdLsVTAnbv5PvnrhTrliV5UmtYhTmQddK28r9fmGKsm2AlHsLd5jkGaU3Z8UwyWzPb1j4sSlMEvC7pPezP6Cg9T7gcQXGTPkzJC9Ts/qxCYowsEQ0SeSz/eKG5072C4i9Mc6SFsRXncH+QLN/9YHLKgMa1wih9F68n6tOrcI0GGT9k= 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)(82310400014)(36860700004)(1800799015)(376005)(7416005);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 May 2024 09:05:10.3203 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6e60ccb4-a7a6-4f96-35cc-08dc69bdcde7 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: BN2PEPF000044A3.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB8101 X-Rspamd-Queue-Id: 97C5F10001B X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: 6fxi6dohrxm13nawd5a9yqmj93uraaeh X-HE-Tag: 1714554313-992767 X-HE-Meta: U2FsdGVkX1+v8h71kJ6iCRkkUH0Ie0zphfisFenUNvWhYvakGclwmKhEbWhgbYtGPx24abarOcVtu32kCko4zUuvkfqBb4n/N1f2OKLKQuaIw2Sf9JhFsq6EybxevN4ISpxoLY0+1POhHjJoGU/KdS8YwSXKzrhzIzNOsQiLvmhCgaVvo5b74XaB79aKGo3FZk0vSZ14p6emX9aHJiQReOt8svSSc6FRzXO2PuyrIMWpty+bhn6An5kmattzuyRJQIAWpcI4cfbnMUDwdEb0GaYa2biiKm1s63tDJ1bHxnHfpVBVbmYXe+PR12FD6K4lRT+g8BV/ZgwHMGYbpBS+Tes2PXKZVaHEkG5DC8YuLbeSqh/M1TVxnJ2l27xC3iT9zi8sVX+fk4QU8lFavhxOoXvVWmnHF8EAAfEnUUJ1pdtQEwLkEXBHdYV4RSyjFw6TG52+MZMb+Bbiv7w7ggm1mZ8+/WiiHcqOj8MwrfJLsHGabilMM78rW5RXUZD1sTZmyYQAuKMIl+SHT/M5D8Cl31vapRpgvttmdHkQ/ebF4P9WkRDqPj7VTQrpLf3/q/VJeTFLnJ6gIjnWn5x6WKiSWYLWHc/ol2spqLImOgbWMC2NZsPxA+gSB3yHXOrPCRHLENO2KTLKhbFKBG3J4tfPDEC6XdpZ/w1rA0xRJr/KnLSJaYl7HPyR9flRxSuxsJp5RHqiaG3bvjJlqU8NbCeE/U5O0e9l+p2nAZDopjYHTpYr5denBwM/gD8qkRieGfoW8aWHAXXwlbM+Q2BChOwXQdhhLsm2094fG7hAzXVNI/LK/MdhQB/PXqnbkxcqSa8ZB/BQfjQdxR0O/4zYQdbC2RbYi7m/mRAIPjisbhgn7sFpEyaL9QyVBe96dwrRF6WY7PDDWIH9VZNiDGagEiCBPPWe7wGQ1LXl8OJu3o1yQTtuRpxzN5aPKbj5WCqZC/azeX7SzELkfSMTyZQvgzn jvMMjMmV eXE3M4QCvs8f4gQ1jHGPlLuMor9wUFBqLFqH30SA4bgZzdH/jWML8/+9WlrzYrQL47Uj9NkCd9B5R9aT2IFFZY8/nqT325JIae0k0tgvC8oe5ZM+YQmDMIBM9Lpfr/kiTY8jISuewIzyEB4mze4mUCs1XL5oYOXyyDxj3yE1BUbc4mocYD+kj8lCYtsxGUQtNj27jOUJ3YryXapvf5TjhB8x105g2YHp2qdziw1/mP7GBBVipSKNwzVuLrJrgoIyN+oMXI/b5O5ROCLpIytqNLr0UOxmYHwh0D/uzPH9XrsEp7iFf5ou74P2B++CJRUGbHGCqyP+ChBh6wFnyIelxJLuKIe6i8yP65ptBlKGvpEGuWZI= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Ashish Kalra With SNP/guest_memfd, private/encrypted memory should not be mappable, and MMU notifications for HVA-mapped memory will only be relevant to unencrypted guest memory. Therefore, the rationale behind issuing a wbinvd_on_all_cpus() in sev_guest_memory_reclaimed() should not apply for SNP guests and can be ignored. Signed-off-by: Ashish Kalra Reviewed-by: Paolo Bonzini [mdr: Add some clarifications in commit] Signed-off-by: Michael Roth --- arch/x86/kvm/svm/sev.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c index 224fdab32950..e94e3aa4d932 100644 --- a/arch/x86/kvm/svm/sev.c +++ b/arch/x86/kvm/svm/sev.c @@ -3039,7 +3039,13 @@ static void sev_flush_encrypted_page(struct kvm_vcpu *vcpu, void *va) void sev_guest_memory_reclaimed(struct kvm *kvm) { - if (!sev_guest(kvm)) + /* + * With SNP+gmem, private/encrypted memory is unreachable via the + * hva-based mmu notifiers, so these events are only actually + * pertaining to shared pages where there is no need to perform + * the WBINVD to flush associated caches. + */ + if (!sev_guest(kvm) || sev_snp_guest(kvm)) return; wbinvd_on_all_cpus();