From patchwork Fri Feb 23 21:16:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Christopherson X-Patchwork-Id: 205696 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp849818dyb; Fri, 23 Feb 2024 13:17:33 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXkZY3ykTs4sAbXJkuRuU5Bd2kk+HchNi9pRL/Qk2fIyhUtg67i0HZrAZIRWDCey/PxSln0Fc50JalQcM700eRE5iuQNw== X-Google-Smtp-Source: AGHT+IFDHBJDfEFLqnjoVG5yoTY09Cr2YgZljVC4mSFvRmn0iIhfM9BSBTmr/dvcv2sXtKXuM3Xj X-Received: by 2002:a05:620a:248b:b0:783:df39:a1cd with SMTP id i11-20020a05620a248b00b00783df39a1cdmr1151897qkn.46.1708723052778; Fri, 23 Feb 2024 13:17:32 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708723052; cv=pass; d=google.com; s=arc-20160816; b=lSBVog+4OYPs5RpvCsmGVJKvrfIGYRHZkL/arXhCFQvlvY/kSeYHOOJNnYry7zilXs WP+BdnFCN5fOaqh8FtSzFvjm0BvMgK2yfCfuNdMMrm2oNElWpxXEcc5PGEiAjc941b5y 2UzI70EyAF3ueDjiTFbNvvoV9XgsIeB7TuJu9xj7Lq9pniOjUG1pMcXQ2yus++lDayK3 vkFaSp5y11KhtlG/CyxwsB65/tYpgLDx9XKjoE3jp/ao7HgASKIIhJ5wTdPlrogO1Qdv /M6SLDys/MMZzyb8eYxcJzQMQrUPzk+x/mHHMTR8nGDl7Lzx++/QXUmUGURDCpd5KSLj J7uQ== 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=2XDFyxdBjQUJNu4zRViJQEh+44N1On/mabiEHEUEPoU=; fh=jCT8ao3IZTJZ7baubN7+IeukAP7qlVAzUEb/oLolRDw=; b=FVprzxtd2nXFFdLM/nxmThRslg545sEGVWpDBxXlgNqTLYeCqFHpnPXUkaTfWGb1aP xAxhDzQ8a+QEOM5nPD91+Xm6oROHHMbCYqfzmC3n9mM9E3/jir8y0wNDDX9HTIE0oMh0 3OgdFJyYsp+vunZFz+KzgYxEvM5j6uCqju5UdJKSNY7HvrcNkde+6ixZOt5HvHLvy0Rt 9HF6oR1LOtVY1MoGNoleN186Gitbi+fFnMjdPmgyTSFwNXUPDFj2PF69jvwqCgl+4ast h9hx+JEjH7F2yQ/qdJESmfLOn9/O7W2RzBxoOGS/lgQbeYMlJcqbX7gik3H7l+Qln98p O01A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=ztmZdLIw; 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-79189-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79189-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id vu16-20020a05620a561000b00785da73ab98si15799854qkn.241.2024.02.23.13.17.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Feb 2024 13:17:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-79189-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=ztmZdLIw; 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-79189-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79189-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 857131C23726 for ; Fri, 23 Feb 2024 21:17:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D45431493AA; Fri, 23 Feb 2024 21:17:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ztmZdLIw" Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.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 D0DCA148FF7 for ; Fri, 23 Feb 2024 21:17:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708723035; cv=none; b=edQ0a50XHXowJoGLhU7r9RCpVtnhUe5ICdctDDrFEab7+dIMhw9nUcPD8bf+gUfzRrAemWcxg81aMzm7yv6821mGzqLNG4A/aiwwhL2oQUvL/SWe+q+Vdi6sRlfhOvAke4IqOjhJvbE/RKnk2blUjk5sztchmmMpmC1IbGkmMys= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708723035; c=relaxed/simple; bh=LxisIv95tuvftO3gGiQktt0Eq+u0gN9VsyqvSkXAJe4=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=nD5GhQYaoTFHG19Q/wsyyPZQIUUkZgUJsujIc5gz0n2Bywvek4X+FLU3/7I9Z0yJ5AGaNYNwmY2idc6cf0s4u57Zi4apeWvtsfYfrzyXKw6svWh8XbLFvew82lRNfull7sVxrT50rZA+ea6ChyzXJo0Oj41RSAXu74Iz22mKC/E= 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=ztmZdLIw; arc=none smtp.client-ip=209.85.128.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-yw1-f201.google.com with SMTP id 00721157ae682-608b648044fso22026897b3.3 for ; Fri, 23 Feb 2024 13:17:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1708723033; x=1709327833; 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=2XDFyxdBjQUJNu4zRViJQEh+44N1On/mabiEHEUEPoU=; b=ztmZdLIwg8YfpJMxhAUzfJZEnwUFV3y9sE0uhfEM8JcMQDcCq9rbEoElyjEXx8N3BR l4BaSZX+enW8V+Xxr2mkAGKAQxy/4K4lWJ+XwQaPWx+z7ynEIsfYlwJdClc12Iy62fdX s1FVvnmmmuFLrmtpASan9HvF7bi8HCJEsy8KLUezdEcATeWdjiQompLMyD/pPKVyxfWB RWmuX0U1dvp/4OzpjVphNbbmbsIBsKlNgtQev0W81GnAwWpHr+ttgdTyuGTAlaQr4mlC IT/wxzDTSuZSY3L6B+tkNHqqouEC2yedGCAFDMnz5vmJs9QReBJjscuU7HBOvBPHDMYB df/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708723033; x=1709327833; 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=2XDFyxdBjQUJNu4zRViJQEh+44N1On/mabiEHEUEPoU=; b=e1XOMcjnz8MGjSYzSzxbgigTsZ8NmW2BBtYVUw1mB7gUkh1II9eT/DzrN7SvweMT+Z 6Ep/mSHTsUH5rBnLBcxfAxyMYqZEVv81NteF/43yahbpJ9gyLvYnE1kKYa+r108jj08t JAs8sM5igtzSVF3cb5crvw4GdYZMsuS35e9Fl33lh8OdRVHSMnV/M/pR6JTOxZ0VkkXT DLth/gQuTi9XoXaz/cw3QNf32KYFtojH3lTJZRKIxyhysKwKgVHf7z4CFvi1YNOyE5ph l7hOnfIdCRj2cwJMQX4v2PJBHsVf1mT4KmS0+l81wej1nJC32LoPCFfQgOgKzkQ5Ooct FIUw== X-Forwarded-Encrypted: i=1; AJvYcCV+ZUQM81MhacSaEK9bnqc3WoAP/0nfJi+gWay8xY80i+Fmt9Sz0H1nuwcwTjm8hFJjeL5rDTHIgH/LYpIt+/0qyQmHQ0ZYNqnJDyB1 X-Gm-Message-State: AOJu0YyMBbwx5ZGFjFtxjHyS9BVwniYvlPJmLFelgmSIxJu+BtsMbxxh aRn2yEDwZHfeqq7cNpBZcztV1Dx2ombJqwF9YdXxj5irx8g4Sb95wlc3LkEYJiD72kaePGm+96I 6fw== X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a81:914b:0:b0:608:b3e0:3edd with SMTP id i72-20020a81914b000000b00608b3e03eddmr232170ywg.3.1708723032945; Fri, 23 Feb 2024 13:17:12 -0800 (PST) Reply-To: Sean Christopherson Date: Fri, 23 Feb 2024 13:16:23 -0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.44.0.rc0.258.g7320e95886-goog Message-ID: <20240223211621.3348855-3-seanjc@google.com> Subject: [GIT PULL] x86/kvm: Clean up KVM's guest/host async #PF ABI, for 6.9 From: Sean Christopherson To: Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Sean Christopherson X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791725984048742298 X-GMAIL-MSGID: 1791725984048742298 An early(ish) pull request for 6.9 (not 6.8!) to clean up KVM's async #PF guest/host ABI. Due to a goof many years ago, the structure shared between the guest and host was expanded to 68 bytes, not the intended 64 bytes (to fit in a cache line). Rather than document the goof, just drop the problematic 4 bytes from the ABI as KVM-the-host never actually used them. The following changes since commit 41bccc98fb7931d63d03f326a746ac4d429c1dd3: Linux 6.8-rc2 (2024-01-28 17:01:12 -0800) are available in the Git repository at: https://github.com/kvm-x86/linux.git tags/kvm-x86-asyncpf_abi-6.9 for you to fetch changes up to df01f0a1165c35e95b5f52c7ba25c19020352ff9: KVM: x86: Improve documentation of MSR_KVM_ASYNC_PF_EN (2024-02-06 10:59:52 -0800) ---------------------------------------------------------------- Guest-side KVM async #PF ABI cleanup for 6.9 Delete kvm_vcpu_pv_apf_data.enabled to fix a goof in KVM's async #PF ABI where the enabled field pushes the size of "struct kvm_vcpu_pv_apf_data" from 64 to 68 bytes, i.e. beyond a single cache line. The enabled field is purely a guest-side flag that Linux-as-a-guest uses to track whether or not the guest has enabled async #PF support. The actual flag that is passed to the host, i.e. to KVM proper, is a single bit in a synthetic MSR, MSR_KVM_ASYNC_PF_EN, i.e. is in a location completely unrelated to the shared kvm_vcpu_pv_apf_data structure. Simply drop the the field and use a dedicated guest-side per-CPU variable to fix the ABI, as opposed to fixing the documentation to match reality. KVM has never consumed kvm_vcpu_pv_apf_data.enabled, so the odds of the ABI change breaking anything are extremely low. ---------------------------------------------------------------- Xiaoyao Li (2): x86/kvm: Use separate percpu variable to track the enabling of asyncpf KVM: x86: Improve documentation of MSR_KVM_ASYNC_PF_EN Documentation/virt/kvm/x86/msr.rst | 19 +++++++++---------- arch/x86/include/uapi/asm/kvm_para.h | 1 - arch/x86/kernel/kvm.c | 11 ++++++----- 3 files changed, 15 insertions(+), 16 deletions(-)