Message ID | 20240203002343.383056-1-seanjc@google.com |
---|---|
Headers |
Return-Path: <linux-kernel+bounces-50769-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp774166dyc; Fri, 2 Feb 2024 16:24:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IFZ/ury55twsNjoW3ikTqobOsOjqY0n58aSFFwInxrFBjVQHXS2O2U1ThXJqUEfyiSUNHGD X-Received: by 2002:a05:6808:23d1:b0:3bf:c79c:ef3e with SMTP id bq17-20020a05680823d100b003bfc79cef3emr2523775oib.42.1706919857608; Fri, 02 Feb 2024 16:24:17 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706919857; cv=pass; d=google.com; s=arc-20160816; b=TuEvslNiQ0kFHdXcdwV1XASa0bf0VlABPvS4LmjUapgsIOriS9Wzcu+n1yau9Uo+zQ GhywhWIs8RJdgYeWF+8K0w6GEBC/OqX/xvp4Y3ynWR+51DwNK6yCnWvzG5FMeh+cM4oz fbPL9nBGe9L3qqAYw1vyJFG/uPjMraKYJ+AizKljMvhxccA3ha4oL1PW/qT+wOetJFzI U7JT+IcB16mGkP6Ix6hy58za3yQVeOZaQ8/FZ7meqImsZp4jt8bSY24Ybqq3z45NBrMz 2DJduFTQRZEIC/JbkwhIJiHr4nLMpdPAGZ6QUv6enlrV0sWcOEiTMvuHOK7WdCBFRWQZ xjwg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:reply-to:dkim-signature; bh=dGotQ4CRNy4fAvOu+oQXTLBsL4Zddq3WhrzF/jyrszE=; fh=xTA/cqE8RjzXHO1pyal5l/PiVFmw5bT7o8IaPbCqyEk=; b=jdFyATgaW0vBKl05K+eUKttaV+XMHJ20YezTGAFwOQDg/WK38PvZkLfV9oUB8j+NK9 80bq4J7nlRLC8443pJ2bdtRZoHQlP6lJQWmlwTByrR4Qp4HOqZJNYKVDQJYzpXo5LKjJ 6OpT9D7WcTzqutNnok+7PUAQlWxH3AjlogIvZFbS28xJa8zlWEzTgYMTj2ZvMliTAPLm RUjLzt2sakaZ+cwQI0PRpo7T7xHUe1e9okpYWYC0g7f7zBrRHp4mW/JeY8LecNc8iW+S TO7OFjPwJe7ZoeLwii2Xboj3FMogREVnDIrQP6DD534/QCrzue0hZR3RVjcgqn+iBV8x rknA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=tMXOhuVu; 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-50769-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50769-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com X-Forwarded-Encrypted: i=1; AJvYcCVy1fBXb6r4ChB1pk85p5nP0809qh5TRkHBNyg+QsVnQ0r6CgvdWoTxKtCo7j94QbvaCrq6NN+S9kdqXatAkLjb/GkQjw== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id z15-20020ac87f8f000000b0042bf6949632si3242601qtj.747.2024.02.02.16.24.17 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 16:24:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-50769-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=tMXOhuVu; 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-50769-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50769-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 654D51C229E7 for <ouuuleilei@gmail.com>; Sat, 3 Feb 2024 00:24:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3FC67522C; Sat, 3 Feb 2024 00:23:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="tMXOhuVu" Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.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 1BF4862B for <linux-kernel@vger.kernel.org>; Sat, 3 Feb 2024 00:23:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706919828; cv=none; b=Gr0BVBwMjFO22utPNqZqM9F5oB9lW/MV0hwTUIfJscuNxnqCWKLzbyVPHkMcRe0eKwkI7RodiJvAOltwWuB0oXUobVidomh/VDjkA3cDBOxcyH8LVa36fA/xoyogIqsc6hZICXduoq7tDC9IVv0zI3JRXe0ntCeYuAVMyGrn1xc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706919828; c=relaxed/simple; bh=Ig5QOPcKdALnxA85Z7llLLp9UDM/G3xlM1p/8HzbKgc=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=lexjZM6BoIKYyCpnmCCT7lHYsKitW+JLUZ81RgAYvxIgZMzYfB1iCYcvxAgRXjMqmAL5wKYoUx417LlOo7fOtBOwGZIe6yYdGjrT2S5SqeIMV8Jzw36qWzMrAiEYb2lRWmlnQxjpRfWwX69QW3CUpj/oWUQivPVVmNtCutThlq0= 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=tMXOhuVu; arc=none smtp.client-ip=209.85.219.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-yb1-f201.google.com with SMTP id 3f1490d57ef6-dc3645a6790so4755058276.0 for <linux-kernel@vger.kernel.org>; Fri, 02 Feb 2024 16:23:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1706919826; x=1707524626; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:reply-to:from:to:cc :subject:date:message-id:reply-to; bh=dGotQ4CRNy4fAvOu+oQXTLBsL4Zddq3WhrzF/jyrszE=; b=tMXOhuVujC0iClLNkuWDTEV8b2v47TEuTJKjJLYYBYxlGmzh6U0ZoJQmhl0/V3zzqn aiIuNXqjIhY/nXNsLLPqyl+AW0vpCLBLhltRLT6gSAUsTNlnv1/IxilXCpCYzNBjzIEq BkVeXg8wmTxAv9+RxjUZ0KwcQReQtIrT2reRDWE+/EibHeRBjTQcRdSumDsawK73qz+2 ZJDl2ln0YjJqdBo/Mq218ND7YeChdE4yQJLdB7DVWVPNsLDnP+93jmnB85/wPbhxDuZW TGPqRnqldn6CLsf/DA5wVOfahFFzBD9KhwGtbqQ4QFRpCGYBeTa8VDTKfmYFoM/3Ksjz dQTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706919826; x=1707524626; h=cc:to:from:subject:message-id:mime-version:date:reply-to :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=dGotQ4CRNy4fAvOu+oQXTLBsL4Zddq3WhrzF/jyrszE=; b=OmAFlATJ5KcgJcJMgFYYvG9kIwdw9jXCneYyfBYpfEQHteBrurecdgQ483L43g9kVE xFU85Hfz/jrSr3Q2uwFC5eyqmUp5OyYwrS2OoVTTeAKUHknd2UnreQdCJIkUrgyt+a9/ lQdDSBZr2ZoSvEMS+fFbSvRL7NoAG0o0GG/1GvT0mEn0TYyHCq7jxVbRQgeD7iD2Kniv 2A4gZxJ2XT2nSNC31G6Kh3NuL3AGUptEAFZ7k9Tgf8o9+gKYItu38yPZAN/jACjAxhlu BPEXZeZDOCmFc2pkuJXd04hyp36y0HJzQ0RAqWgL/Is0RUmN3dsyH2XmSSZegCiJsCDs m8ww== X-Gm-Message-State: AOJu0YwOKXCHjFTlN6e+lc5w00W/di/cQf+BAwmZypt0HbspKo5Tyb7l vv6w4m/zPONXs44CWxrAdFpBzxCHEWG0KWDV53U52Vz5aUXqi86JPpFUKtV/qjgvoYhOVqON3BJ xQQ== X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:6902:2512:b0:dc2:1dd0:c517 with SMTP id dt18-20020a056902251200b00dc21dd0c517mr2477010ybb.7.1706919826067; Fri, 02 Feb 2024 16:23:46 -0800 (PST) Reply-To: Sean Christopherson <seanjc@google.com> Date: Fri, 2 Feb 2024 16:23:39 -0800 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 X-Mailer: git-send-email 2.43.0.594.gd9cf4e227d-goog Message-ID: <20240203002343.383056-1-seanjc@google.com> Subject: [PATCH v2 0/4] KVM: x86/mmu: Clean up indirect_shadow_pages usage 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, Jim Mattson <jmattson@google.com>, Mingwei Zhang <mizhang@google.com> Content-Type: text/plain; charset="UTF-8" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789835196386456787 X-GMAIL-MSGID: 1789835196386456787 |
Series |
KVM: x86/mmu: Clean up indirect_shadow_pages usage
|
|
Message
Sean Christopherson
Feb. 3, 2024, 12:23 a.m. UTC
Resurrect a 6 month old patch from Mingwei, add a few cleanps on top, and fix a largely theoretical race between emulating writes and write-protecting shadow pages. At least, I'm pretty sure there's a race. Memory ordering isn't exactly my strong suit. v2: - Drop the unnecessary READ_ONCE(). [Jim] - Cleanup more old crud in reexecute_instruction(). - Fix the aforementioned race. v1: https://lore.kernel.org/all/20230605004334.1930091-1-mizhang@google.com Mingwei Zhang (1): KVM: x86/mmu: Don't acquire mmu_lock when using indirect_shadow_pages as a heuristic Sean Christopherson (3): KVM: x86: Drop dedicated logic for direct MMUs in reexecute_instruction() KVM: x86: Drop superfluous check on direct MMU vs. WRITE_PF_TO_SP flag KVM: x86/mmu: Fix a *very* theoretical race in kvm_mmu_track_write() arch/x86/kvm/mmu/mmu.c | 19 ++++++++++++++++--- arch/x86/kvm/x86.c | 35 ++++++++++++++--------------------- 2 files changed, 30 insertions(+), 24 deletions(-) base-commit: 60eedcfceda9db46f1b333e5e1aa9359793f04fb
Comments
On Fri, 02 Feb 2024 16:23:39 -0800, Sean Christopherson wrote: > Resurrect a 6 month old patch from Mingwei, add a few cleanps on top, and > fix a largely theoretical race between emulating writes and write-protecting > shadow pages. At least, I'm pretty sure there's a race. Memory ordering > isn't exactly my strong suit. > > v2: > - Drop the unnecessary READ_ONCE(). [Jim] > - Cleanup more old crud in reexecute_instruction(). > - Fix the aforementioned race. > > [...] Applied 1-3 to kvm-x86 mmu. I will likely apply patch 4 for 6.9 as well, but assuming it doesn't get attention "soon", I'll apply it dead last in kvm-x86/mmu so that it's easy to discard if my paranoia is unfounded. [1/4] KVM: x86/mmu: Don't acquire mmu_lock when using indirect_shadow_pages as a heuristic https://github.com/kvm-x86/linux/commit/474b99ed703b [2/4] KVM: x86: Drop dedicated logic for direct MMUs in reexecute_instruction() https://github.com/kvm-x86/linux/commit/515c18a64e70 [3/4] KVM: x86: Drop superfluous check on direct MMU vs. WRITE_PF_TO_SP flag https://github.com/kvm-x86/linux/commit/dfeef3d3f310 [4/4] KVM: x86/mmu: Fix a *very* theoretical race in kvm_mmu_track_write() (not applied, yet) -- https://github.com/kvm-x86/linux/tree/next