[14/16] KVM: x86/mmu: Set kvm_page_fault.hva to KVM_HVA_ERR_BAD for "no slot" faults
Message ID | 20240228024147.41573-15-seanjc@google.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-84440-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp3115661dyb; Tue, 27 Feb 2024 19:34:56 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXBXKR8+FpU6PykqVsndUQKHRSJybcwjlbntdytcYEN/WmYfXIq3qiqSXuFjqtfxk6IIQLarlvB980hzmDaBGqSL2o+DA== X-Google-Smtp-Source: AGHT+IHNxgofYgVlOoAbxEYB1SDI5HyP/aIYvZ012uVuqlVjDGtrnXvvW7JyXQQ4zOeNptHCA1A4 X-Received: by 2002:a05:6a21:8cca:b0:19c:a202:3f96 with SMTP id ta10-20020a056a218cca00b0019ca2023f96mr5202182pzb.51.1709091296379; Tue, 27 Feb 2024 19:34:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709091296; cv=pass; d=google.com; s=arc-20160816; b=a3nIKt0Za1/fQXN7OSL52PpRgJP8YEw9KFQomNLdD9Lgk7kce88hYpXh84WCPp2ILH btU9x7A5FIG1xyWKmuF5TmAVBKbKrFy77alfbXnfZaRS+Wmps5uv4T25pVDP/ZAplV53 lu9PNPli9/hGMzIeRnpk89ooxOWEc+CXbL98te8Pkq7aQzsWT1Bc0xFQx2GNc0fHF3nD Pp1h164Qk6efqQoCTVIV9wqLRCimWFxTMIb3hQWgYVxnYZHF84l+yXEBLfk08VrOL39O R2Do4ySDPXc+U0K/Kdx4mXBeDKP+jTZLABFEco5eAurOC71DNNB5rTjGBVYiZ9C9ihNF 6LyQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:references:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to:date :reply-to:dkim-signature; bh=za8QaygzoKIY5MyMe/Z2Ubm1oLIN1MbBZtglXwIHigs=; fh=h/ygJ9IAucyGQlZ9ThMFX1JZLZyRWSl8Je6erbgpHPg=; b=PAPSdMpB2cu1rhtpfVi7UI8T4IpulFASD+xVtUF7qZTcmbYLt133OHRvwtUK8PsrOD u60slbl1KhQkmjNrzz1U/RJPX/bNEwuZX6VlMvNCE88Wi+QMTWpYM9BTEzulRfXHtTV4 imAF5FzMz7q3f71JcTeHhaHOaOyTNlMi1KFTNhx9cThnUROH5cMjslsteE9FTuW6mr/I bbqvajHLJIiSwKRFxF2a7aB8TMpbzQIkYnyrv2Mpp/glO7O8liZb5pz76ROICjdQFsK9 1lcsS4MiTlbUrWnOQiWZ9IQ72/FO11yqf9B+vyyaAxaD4LI7atAr6RiKCjKGKUamgkIz QwEw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=B2DwrAqe; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-84440-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84440-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id s19-20020a632c13000000b005dc864bb6e6si6748740pgs.634.2024.02.27.19.34.55 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 19:34:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-84440-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=B2DwrAqe; arc=pass (i=1 spf=pass spfdomain=flex--seanjc.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-84440-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84440-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id D5905B26BC9 for <ouuuleilei@gmail.com>; Wed, 28 Feb 2024 02:46:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id ECE8C2E84F; Wed, 28 Feb 2024 02:42:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="B2DwrAqe" Received: from mail-pg1-f201.google.com (mail-pg1-f201.google.com [209.85.215.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 97B9C25566 for <linux-kernel@vger.kernel.org>; Wed, 28 Feb 2024 02:42:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709088139; cv=none; b=KocNDApRuuS/TEzmoPnpdr51nyaWQql4v0wOY3nau2fzzKRk5Ub5uk6uqdiesGbLadi8II4sWMcbQwOyFmtIzpE+nUtAy0S/gC5CC1f8dXcI7ybLOqfyzhD1Gg6atWm0IVkSTVTazFmkA/Cqcka6Rk7frj7PiZ7k8FfITSDBjQM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709088139; c=relaxed/simple; bh=JLsN4xg251qE9a3MZGdWpvkmGCZsQVcBJtHNmsnHqx0=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=D+8up5P0Cwk7Z13SaB82BFsiLSw1intS5mt9FsVk4eQIzkUg2G37rXYQ+AWa9nCjgDxwrYEnkvvLZ7oG3rkMiNfVs4Zns+dvS7GkqYe4OpbRyd1mPHq042OwS6lipGVijYyvIeTgprhaJaIQ3aVgAxN5gz0s5XZWegdnRKYMcig= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=B2DwrAqe; arc=none smtp.client-ip=209.85.215.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Received: by mail-pg1-f201.google.com with SMTP id 41be03b00d2f7-5cf555b2a53so304953a12.1 for <linux-kernel@vger.kernel.org>; Tue, 27 Feb 2024 18:42:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709088137; x=1709692937; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=za8QaygzoKIY5MyMe/Z2Ubm1oLIN1MbBZtglXwIHigs=; b=B2DwrAqeZ3hxUE5PrHwB//zObnj3gOVUrBHZ7xlBCCpYJwsaZsujU1Wd6wRYLYKFVQ ciPVYnK1SHSFjRSfWcz7DzJ+KuBdcNZaVAp6YQxNlQrmZ9ozftnUOEf9bEVq6FwNyGZT uUcqGZbU2HNYM7KrHo3KmJ3Inmi3YIJoXDEDlrG5x1iddFnp9C48nEQ/1+7Hl1TrilfH 1qri28/ll7THvl6UBOzAy/IWkLi/YqZIdINLf52ijL2HEPWA9UL9M785vvTRjSWr1j7t FZnkQP1xBcX2LzHqHTFuGrsctfXMggNxh6HQiut930hQsKBmCOHK/+EpKSutmNoTP26H Gtuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709088137; x=1709692937; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=za8QaygzoKIY5MyMe/Z2Ubm1oLIN1MbBZtglXwIHigs=; b=e5ejnIR19Qolhbca8xPcAiE4CbjHHKo2gqnykfGQP4zQdHu+hk08fwW8bTEPMPWoso pBzXER+rdMAwcnFKgfZfayC5Y0tRgKQcY64ewfYy7bILtzapPoxjCJzt3rDfoFb+f02j JFoijE5mhM0K9wgj/TC1Oh6CYDR/GVWvdkcutsFssTH8GEGCisPxzE1IEWdIEA7ykhBE zauMEnHfQurhBYL9k24/t0Shu6YldrbIurO46m8kvoEGd3tCdU9slFjGbMCAd4R1024s WRdTrhlSxtxmp8TLVOh2wZfdyKSyYnTMA8V0m6Tjy9u0l/opz/CmPwupEhYSWMPYXxRz m6Lw== X-Forwarded-Encrypted: i=1; AJvYcCUsxrvWt2GowtecU3FClGzQ9D/+V1tCQhp8tFei36SlZA1l9M6+HZCcrTGgDPe5pSlxbewzX/Use7VU4KVAUIWfou0QmmW9IzAsByxM X-Gm-Message-State: AOJu0YyPEzk4xvq0m7NGWnYglDKa2dfpQYfSpRcgfoln/1LjOEagSyOx Kf+nfj956sqDynlN1KGbNWg4tmc1odlun0V/MEB0L+RBKbXMz7cPiLw+jP9CTMswPws1IPyCdxa 8cA== X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a17:902:fa83:b0:1db:a739:d17b with SMTP id lc3-20020a170902fa8300b001dba739d17bmr2743plb.1.1709088136837; Tue, 27 Feb 2024 18:42:16 -0800 (PST) Reply-To: Sean Christopherson <seanjc@google.com> Date: Tue, 27 Feb 2024 18:41:45 -0800 In-Reply-To: <20240228024147.41573-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> Mime-Version: 1.0 References: <20240228024147.41573-1-seanjc@google.com> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog Message-ID: <20240228024147.41573-15-seanjc@google.com> Subject: [PATCH 14/16] KVM: x86/mmu: Set kvm_page_fault.hva to KVM_HVA_ERR_BAD for "no slot" faults From: Sean Christopherson <seanjc@google.com> To: Sean Christopherson <seanjc@google.com>, Paolo Bonzini <pbonzini@redhat.com> Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Yan Zhao <yan.y.zhao@intel.com>, Isaku Yamahata <isaku.yamahata@intel.com>, Michael Roth <michael.roth@amd.com>, Yu Zhang <yu.c.zhang@linux.intel.com>, Chao Peng <chao.p.peng@linux.intel.com>, Fuad Tabba <tabba@google.com>, David Matlack <dmatlack@google.com> Content-Type: text/plain; charset="UTF-8" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792112115457894761 X-GMAIL-MSGID: 1792112115457894761 |
Series |
KVM: x86/mmu: Page fault and MMIO cleanups
|
|
Commit Message
Sean Christopherson
Feb. 28, 2024, 2:41 a.m. UTC
Explicitly set fault->hva to KVM_HVA_ERR_BAD when handling a "no slot"
fault to ensure that KVM doesn't use a bogus virtual address, e.g. if
there *was* a slot but it's unusable (APIC access page), or if there
really was no slot, in which case fault->hva will be '0' (which is a
legal address for x86).
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
arch/x86/kvm/mmu/mmu.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c index 4dee0999a66e..43f24a74571a 100644 --- a/arch/x86/kvm/mmu/mmu.c +++ b/arch/x86/kvm/mmu/mmu.c @@ -3325,6 +3325,7 @@ static int kvm_handle_noslot_fault(struct kvm_vcpu *vcpu, fault->slot = NULL; fault->pfn = KVM_PFN_NOSLOT; fault->map_writable = false; + fault->hva = KVM_HVA_ERR_BAD; /* * If MMIO caching is disabled, emulate immediately without