From patchwork Wed Feb 23 05:22:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Junaid Shahid X-Patchwork-Id: 12756399 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 C1DEFC433F5 for ; Wed, 23 Feb 2022 05:25:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E129C8D000F; Wed, 23 Feb 2022 00:25:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DC3258D0001; Wed, 23 Feb 2022 00:25:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C63A18D000F; Wed, 23 Feb 2022 00:25:13 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0144.hostedemail.com [216.40.44.144]) by kanga.kvack.org (Postfix) with ESMTP id B68B98D0001 for ; Wed, 23 Feb 2022 00:25:13 -0500 (EST) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 7AD04181CA34A for ; Wed, 23 Feb 2022 05:25:13 +0000 (UTC) X-FDA: 79172906106.16.E4C9F6A Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) by imf09.hostedemail.com (Postfix) with ESMTP id 0FD64140002 for ; Wed, 23 Feb 2022 05:25:12 +0000 (UTC) Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-2d07ae11467so163393527b3.12 for ; Tue, 22 Feb 2022 21:25:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=Kqez4sz2gXA92s/yKdI0Sadgd/VKyd58nC75f61sH3c=; b=kY6HPVZ5+V/4ADSj5gTm7IQPleGSUbrDBXkArXIMxRp8wv39Fiygf+bF+YqLodOTpp AZsLSr13DzroNgqyc8IDfXzcQUL9DyFnAH4zuxHj+73S9iVBPAI2bhK64r7+IZ9iPw2j l6U45p4hnLVXIe3HFpHe4qJp9mEpOsCgXDx6xEMFZlJGN4bxSQMLkshnkvHzcWhTYszS 3RalZYOgTpQ3xR1RbA6oUKLNH9FzKB/Oq6geEXx6xglDHFlrVYGZZaZlqsNdHMvuOFaS qOuzTGhwZjX65TLhLW2uhuxlSD1GB251cNcp9nHh4Mb+0b/OHXDC3ll2brbPttKVPhId WuIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=Kqez4sz2gXA92s/yKdI0Sadgd/VKyd58nC75f61sH3c=; b=rxy/23w1RaJ1Og8OPhJvYa8pzfAUrNvPSnZRxlpXdUAUiUZ9w/FX+Og3oeX60u9Las J2/142yw83ymk7znlfese1uzHFLSYPi/Z8E04AFUeI58dnCTPpa/zgy/5mukd0VhGe48 JRzfC74wnZ0tEM2OmZEl0n5BdOxDqEM7ml7Myi4/DkUul8bIv+ExYxi0N7yrRF6yWQBX yqbjyOoiQLBhirBg9JvWgZ5AnnP1hQGhCt0uBs7iYHvtngEt5mUozPoCLs5eEu1XWLWd 11Bt+odL2EucE+91VMnt+RsOijymjB6jkvf42Rt4XXuMpMubNeHMOPscu4gzzBowoEz0 OPtw== X-Gm-Message-State: AOAM533R76bVzaKzhGoadQeW9N4lz5qnnHs7OMfFBYGd4L1cBwe8aHyy COU7ua02VcsHzcXX15fvvJwGMgndRqO5 X-Google-Smtp-Source: ABdhPJwRpDGu9uCaO7SUVy/qucopgnc8bRss4/HLiRU4Az2YJmA6Oz65Xuo4RY/0idM9yle+QHSTEPNKFl9M X-Received: from js-desktop.svl.corp.google.com ([2620:15c:2cd:202:ccbe:5d15:e2e6:322]) (user=junaids job=sendgmr) by 2002:a25:34c9:0:b0:623:fc5f:b98 with SMTP id b192-20020a2534c9000000b00623fc5f0b98mr27190113yba.195.1645593912355; Tue, 22 Feb 2022 21:25:12 -0800 (PST) Date: Tue, 22 Feb 2022 21:22:15 -0800 In-Reply-To: <20220223052223.1202152-1-junaids@google.com> Message-Id: <20220223052223.1202152-40-junaids@google.com> Mime-Version: 1.0 References: <20220223052223.1202152-1-junaids@google.com> X-Mailer: git-send-email 2.35.1.473.g83b2b277ed-goog Subject: [RFC PATCH 39/47] mm: asi: Skip conventional L1TF/MDS mitigations From: Junaid Shahid To: linux-kernel@vger.kernel.org Cc: Ofir Weisse , kvm@vger.kernel.org, pbonzini@redhat.com, jmattson@google.com, pjt@google.com, alexandre.chartre@oracle.com, rppt@linux.ibm.com, dave.hansen@linux.intel.com, peterz@infradead.org, tglx@linutronix.de, luto@kernel.org, linux-mm@kvack.org Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=kY6HPVZ5; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf09.hostedemail.com: domain of 3OMUVYgcKCDEWhaNVQfTbbTYR.PbZYVahk-ZZXiNPX.beT@flex--junaids.bounces.google.com designates 209.85.128.201 as permitted sender) smtp.mailfrom=3OMUVYgcKCDEWhaNVQfTbbTYR.PbZYVahk-ZZXiNPX.beT@flex--junaids.bounces.google.com X-Rspam-User: X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 0FD64140002 X-Stat-Signature: sp7q68onb45hnfbh4kaqabt41optha5f X-HE-Tag: 1645593912-397160 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: From: Ofir Weisse If ASI is enabled for an mm, then the L1D flushes and MDS mitigations will be taken care of ASI. We check if asi is enabled by checking current->mm->asi_enabled. To use ASI, a cgroup flag must be set before the VM process is forked - causing a flag mm->asi_enabled to be set. Signed-off-by: Ofir Weisse --- arch/x86/kvm/vmx/vmx.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index e0178b57be75..6549fef39f2b 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -6609,7 +6609,11 @@ static noinstr void vmx_vcpu_enter_exit(struct kvm_vcpu *vcpu, kvm_guest_enter_irqoff(); - vmx_flush_sensitive_cpu_state(vcpu); + /* If Address Space Isolation is enabled, it will take care of L1D + * flushes, and will also mitigate MDS. In other words, if no ASI - + * flush sensitive cpu state. */ + if (!static_asi_enabled() || !mm_asi_enabled(current->mm)) + vmx_flush_sensitive_cpu_state(vcpu); asi_enter(vcpu->kvm->asi);