Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp3166207pxb; Tue, 12 Jan 2021 07:54:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJz9v4Vlbn8ioo36IxWH/cZUyyv+DFBmiwEbW3X7X8FBy1w5RpfJDkzX3g4nPsKmcS8+Iay0 X-Received: by 2002:aa7:c78c:: with SMTP id n12mr3949772eds.363.1610466873086; Tue, 12 Jan 2021 07:54:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610466873; cv=none; d=google.com; s=arc-20160816; b=m9BdUpJoLbzaWuZ5zKg3eY80bJuGgH3jY54PPYrHReRWGMk0KCoefeDSB95qrj87n+ AuACXNRSxJS2ukFzcdqLmznGHz9TmecT9DQQs2Fd6YHyRkLipIxT3dbkpbi6wltarhIl cj/YERCcmzIK0d1Eyo1yAU106NT3zMA28WBjGx4iByWK6n2cDgPr7HzNFlIbmplqbLqG re6AoVKzw6n+pX1GNuQ0fbMJwETafn1+zyKheq7rxTb1gmGoasBBCdKKjOU2zulW5VAJ cBrIok8SD1y1e15rNG/2QOKSA0pHfTf0RVq7Zz/TIJHaDW1mGtz15SmqnRtWaVT6blMu Flgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:in-reply-to:cc:references:message-id:date :subject:mime-version:from:content-transfer-encoding:dkim-signature; bh=meDQXX3XD75fr/Eh+OZMYbgkflSWbsrFgrToIxKFeB8=; b=Nw68VmeqE4u5JHUZ3SUgzLZiY8rsGelZQiSvmY2s8ZRFDxLruAOCF7sssNZB7Fn7MG VnsfmHRAQlowg/LFsuas+qU5Cxv2WgnRYmsW0xFYhCxm/T89JtvxlmUMeb+1LUw91p2Y bRY8cMpdPvwZJN3i6cBK5nUU5PfoCnQ3mlRYtUvVvvfuZNUZHadmoXJIF8Z+3ZgXfB9c 3aMogtXEnJMaLOxwtc5qDHxAG7TORHGOH+opdEkyajJE5FuwnsAVax8osnct00LIOYOV +tRJDXP25VwdjA7TRXLRXaEJ9btHupe0dI+6uKxFFI2wlkWeBjvxnp124DW2lWowcTeF 77+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b=RZrg0tk6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s2si1515100edw.5.2021.01.12.07.54.09; Tue, 12 Jan 2021 07:54:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b=RZrg0tk6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392085AbhALPwE (ORCPT + 99 others); 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-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