From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AB9C0C433E9 for ; Tue, 12 Jan 2021 15:52:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 66CC320656 for ; Tue, 12 Jan 2021 15:52:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392089AbhALPwE (ORCPT ); Tue, 12 Jan 2021 10:52:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2392064AbhALPwD (ORCPT ); Tue, 12 Jan 2021 10:52:03 -0500 Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3CAB7C061795 for ; Tue, 12 Jan 2021 07:51:23 -0800 (PST) Received: by mail-pf1-x434.google.com with SMTP id d2so1620315pfq.5 for ; Tue, 12 Jan 2021 07:51:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amacapital-net.20150623.gappssmtp.com; s=20150623; h=content-transfer-encoding:from:mime-version:subject:date:message-id :references:cc:in-reply-to:to; bh=meDQXX3XD75fr/Eh+OZMYbgkflSWbsrFgrToIxKFeB8=; b=RZrg0tk6bQj6DM1AY7MNXKv0DnzfmYK79bq8YdEH9FgAWrXF1PWqAgRIuyDTG2x1Ue Kq7t8LhYNncsed4/aJtjfDjt5Q+/IDfcIfj4z8vImrp9Unrey24ogvuDw6mWPO57GOiY mUeWmw3DU9OI1VrqFTdtR5xqdIGczh/qwfRsIAWMjWXwc9A7IcVBfOCWjcsHORg96squ rfls/Pd0lBtrHN8nyBh9tFE0xy38qWk5fl+z7ZDxucHiM+mFW/NyPqb2DBv3b7YeGoM0 Va7/xZNPnjH9fPd5Avq8igc18BEEpC2bEm/kD4ijfDtA17nBo+jSxSDp1xC0AtPa/5vW eAPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:content-transfer-encoding:from:mime-version :subject:date:message-id:references:cc:in-reply-to:to; bh=meDQXX3XD75fr/Eh+OZMYbgkflSWbsrFgrToIxKFeB8=; b=Pnq6kEdNGQeI6HhWvyfTmrwnkRP4FPv+w9ZW8pSTEhMk9Ec3Q46gwm7HhhNOqr+SNC MugN9DXQUf4kr9tFl9YCrNO3PXmUMdzWJ6IKFL4hfrxiusFPQdc9E3tnDMLSLEdrtWLe /Wc33k9a1FTJ1PMwT77VWqDLjcnk6HwAyQUN1PbSV4mDShXSbn68Sb3swwF2nDiWYoGR FpIxy1JkpU7qQG3Hx6dRqR96J1zjXNSEhyWbha6FsErofGtlkkhNAb5yGHEiCslHEu4v DDkNhCinm5VHWvNSDrVfYfRoaQ/47cYuNO2KfCFebAsGssjR7zSsA6XZlyMjfk5e3HcJ U/QA== X-Gm-Message-State: AOAM5325e2SIlP3kFWuGHOnrLkFFCk5So8E1cXa7ZkkZs6j1XF++P/MY fPJ2e6RwaQzaXkf6LIZiLygWQQ== X-Google-Smtp-Source: ABdhPJwa0jFvja1e809QMhaIsVsedI0V1Nmc2CmTBYN6vm75qgQa7r6ag6ohSpXAYbQeMQ/UZSWv9A== X-Received: by 2002:a63:2347:: with SMTP id u7mr5279301pgm.189.1610466682707; Tue, 12 Jan 2021 07:51:22 -0800 (PST) Received: from ?IPv6:2601:646:c200:1ef2:1d60:88a3:44d6:6b86? ([2601:646:c200:1ef2:1d60:88a3:44d6:6b86]) by smtp.gmail.com with ESMTPSA id k15sm3625781pfp.115.2021.01.12.07.51.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 12 Jan 2021 07:51:21 -0800 (PST) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: Andy Lutomirski Mime-Version: 1.0 (1.0) Subject: Re: [PATCH 1/2] KVM: x86: Add emulation support for #GP triggered by VM instructions Date: Tue, 12 Jan 2021 07:51:19 -0800 Message-Id: <8FAC639B-5EC6-42EE-B886-33AEF3CD5E26@amacapital.net> References: Cc: Maxim Levitsky , Vitaly Kuznetsov , Wei Huang , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, pbonzini@redhat.com, seanjc@google.com, joro@8bytes.org, bp@alien8.de, tglx@linutronix.de, mingo@redhat.com, x86@kernel.org, jmattson@google.com, wanpengli@tencent.com, dgilbert@redhat.com In-Reply-To: To: Bandan Das X-Mailer: iPhone Mail (18C66) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On Jan 12, 2021, at 7:46 AM, Bandan Das wrote: >=20 > =EF=BB=BFAndy Lutomirski writes: > ... >>>>>> #endif diff --git a/arch/x86/kvm/mmu/mmu.c >>>>>> b/arch/x86/kvm/mmu/mmu.c index 6d16481aa29d..c5c4aaf01a1a 100644 >>>>>> --- a/arch/x86/kvm/mmu/mmu.c +++ b/arch/x86/kvm/mmu/mmu.c @@ >>>>>> -50,6 +50,7 @@ #include #include #include >>>>>> +#include #include >>>>>> "trace.h" >>>>>>=20 >>>>>> extern bool itlb_multihit_kvm_mitigation; @@ -5675,6 +5676,12 @@ >>>>>> void kvm_mmu_slot_set_dirty(struct kvm *kvm, } >>>>>> EXPORT_SYMBOL_GPL(kvm_mmu_slot_set_dirty); >>>>>>=20 >>>>>> +bool kvm_is_host_reserved_region(u64 gpa) +{ + return >>>>>> e820__mbapped_raw_any(gpa-1, gpa+1, E820_TYPE_RESERVED); +} >>>>> While _e820__mapped_any()'s doc says '.. checks if any part of >>>>> the range is mapped ..' it seems to me that the real >>>>> check is [start, end) so we should use 'gpa' instead of 'gpa-1', >>>>> no? >>>> Why do you need to check GPA at all? >>>>=20 >>> To reduce the scope of the workaround. >>>=20 >>> The errata only happens when you use one of SVM instructions in the >>> guest with EAX that happens to be inside one of the host reserved >>> memory regions (for example SMM). >>=20 >> This code reduces the scope of the workaround at the cost of >> increasing the complexity of the workaround and adding a nonsensical >> coupling between KVM and host details and adding an export that really >> doesn=E2=80=99t deserve to be exported. >>=20 >> Is there an actual concrete benefit to this check? >=20 > Besides reducing the scope, my intention for the check was that we should > know if such exceptions occur for any other undiscovered reasons with othe= r > memory types rather than hiding them under this workaround. Ask AMD? I would also believe that someone somewhere has a firmware that simply omits= the problematic region instead of listing it as reserved. >=20 > Bandan >=20 >=20 >=20