Received: by 2002:ab2:6d45:0:b0:1fb:d597:ff75 with SMTP id d5csp240733lqr; Wed, 5 Jun 2024 04:59:24 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWoewVGqud7DyyesaljXF3217HCOIqtC9Hb4jIYB9eRLTfTeTjonVAvP5qLeXdkpjxOKH7R/NOl8ZogjfJ5v/3m6W5fIwldA+eKX8KyNg== X-Google-Smtp-Source: AGHT+IEZORfa0CKMm7FJHOlFmdVhgOe7tTs5dY8ftqBbjY4TQhDfcgyVGFRzkCK3RBcUL/zoFhUv X-Received: by 2002:a05:6359:4c1a:b0:19c:3e66:d00d with SMTP id e5c5f4694b2df-19c66db04cemr259504655d.5.1717588764170; Wed, 05 Jun 2024 04:59:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717588764; cv=pass; d=google.com; s=arc-20160816; b=AfahbpESHN7fUejUgZehPt6CH1XFZCfOaEEniolKsACzM9/GCgBtOx0FeOYKnQ0Cl8 HaIqVgwzANrRWwFxPGGWnl72g4tDTQvmL0X1Y78pI1b83LmOtfiKxsEYdv9RORotfgn5 vyEV48JTEYVzU2PK3EO/MMxx8Dw4ofpTbwiLowGqPAHjmwf7ERAnh2iVzykj7wj9C+8v MIsWxTircxwWWzLTw63bIPLpUJVCF38Ia3YzQdOx47+ihiKq2NAaQ6QcFR69ZtkLQfgG aQJ/XeagLqBr/0BugllE1TAVMgyX8GOR0+8ItkZaPSRKrtr2U/YKcBpr0JTt/GysDhSi GxGw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:from :dkim-signature; bh=C/NY/2YjV6Vm60nz2Zgxno4gkWgzFmF8Hp1gw9FQBwo=; fh=hBZNaBlMLRepPz1w2wBf8TAACz89vdGFJHmZGymLCoU=; b=uLdfAfBQL+ETuNRoTOrW+Vl4K1uhmuGM8R3Yd5uKeThNkR1G4lMBZ+5ZUbxoGm1aaX xRvRs3EQ033qaMOJv3sBAj2rHArMUAHpg9N0sLJMgqOxWhC9kvVvacitJ/NpMEgQzZyR yJOUPXgHUeD6zts1J/9MPLllLXxm0IDXF8CBCdU4TO1hm8iIWKFubM+ZeT9iQQb3ctUY BHtY9++r1ebFneURl0Uo4+5I6YF6Q9gqvn15Evj+lYgJ071l/vOpI0dK1lsb2JFzmNL0 zE5Jl9hLfoDy1l84Vw36GC7zU6OMBp5eZ3XYNNEPIQoQy99cbXQJnDnahjMHwgWNwqJW qdZA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Keh9xRST; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-202311-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-202311-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-6c35c73c83fsi1682684a12.781.2024.06.05.04.59.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 04:59:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-202311-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Keh9xRST; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-202311-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-202311-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 05318B23EED for ; Wed, 5 Jun 2024 11:53:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B6F7B195F14; Wed, 5 Jun 2024 11:50:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Keh9xRST" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E0CB3195F0C; Wed, 5 Jun 2024 11:50:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717588205; cv=none; b=pq6+7ezT4tlVZQsRJa3IgLMD/YH6K7tLbf7kPhua2NYGeVztUOvGwUhaZhGAWoByJkA2+xiXsW6dIx2yW8y74RxdCVJP1TFKu5+GUUi5FkwDLcuLeMf2Emck7wFJxqZy0YFQ/llnihuX5jvZdvcOEKx1/rQP+iEy0tyXsc/6Ma0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717588205; c=relaxed/simple; bh=SBQCKZifEPOxIOTgbUM/XODaGoNdobSf2QES1yw7iAA=; h=From:Subject:Date:Message-Id:MIME-Version:Content-Type:To:Cc; b=EO++8lOSC004RVn7e8vXDeOzgFBKzBBfC0A4cmnODY4218cTrmPzmFziymKpVp3srH3v0pIQ4Uy7THgbVfU9hL2UDvBdwO7UJlH0qa92eZp5HjN8t5VlGAHhucxfU9pm2FPjb6rJ7Sqo81jnPmYbQ/VY0r0HeoYYYAu5IaY3B44= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Keh9xRST; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3A1A4C32786; Wed, 5 Jun 2024 11:50:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717588204; bh=SBQCKZifEPOxIOTgbUM/XODaGoNdobSf2QES1yw7iAA=; h=From:Subject:Date:To:Cc:From; b=Keh9xRST+Rj9UveGAcphGxlIbytEGvAKf2tTEbsoLlQaSP+AAoKYPqRrgCmMPe4fh CfWxq8d6wIzS/I8AhgK2lJnaMBtoP9+O9JUzkAeEq1DurTwsXwplNLZCcW6nJxJtNl PJ2fCjhd2FD5CDrjIZvXqMC+naEPhGr/TT2JzAsafNVdu1hpSe5p/o0uHusoNcWeYU cHs+t7SLNj6wTzERdP5pm5jlunM/RyaYM8x4nfHYCBbQQz3TyXEeOzozOjuORdyWSt 2v/b/aICBkJJP8Yc+5KFaaPoDnbjwi1U+VmAJAHFwMBNvLHltubSoLFUGdNzCuoUeG CtJI9PDr/Hf7A== From: Mark Brown Subject: [PATCH 0/4] KVM: arm64: Fix underallocation of storage for SVE state Date: Wed, 05 Jun 2024 12:41:26 +0100 Message-Id: <20240605-kvm-arm64-fix-pkvm-sve-vl-v1-0-680d6b43b4c1@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-B4-Tracking: v=1; b=H4sIAOdOYGYC/x3MQQqAIBCF4avIrBvQkoSuEi0qpxrKEgUJpLtnL T/438sQKTBF6ESGQIkjX2eBqgTM23iuhGyLoZa1lq3UuCeHY3CtxoVv9B9jIkwHqma2Ri3W2El C2ftAJfm/++F5Xi6OVr1rAAAA To: Catalin Marinas , Will Deacon , Marc Zyngier , Oliver Upton , James Morse , Suzuki K Poulose , Fuad Tabba Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kvmarm@lists.linux.dev, Mark Brown X-Mailer: b4 0.14-dev-d4707 X-Developer-Signature: v=1; a=openpgp-sha256; l=1401; i=broonie@kernel.org; h=from:subject:message-id; bh=SBQCKZifEPOxIOTgbUM/XODaGoNdobSf2QES1yw7iAA=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBmYFDm6hO8bPCS7tdj//OV90xJulySV0nlZRmUoVx7 atNp/EeJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCZmBQ5gAKCRAk1otyXVSH0NmEB/ 9kIzl7JVowupzSHv5DNrF6MZgboFE8vKIcWYpcWQXTx0AJb/cC+D0KcIPrxQM0CnuFeUaxA3Lh8ni4 wxwSqyA302Vwl35F3cIRN6dXsWtbVz4U9ztR3Kz6N0EufvQL5ipNOkWhvnDcwX7aCIfJl0cfDqB1qW asqTC8yHBCNu627cZ9MzeWhPJlDuw4PrfdyhT7jdpWXJA2X9JpylQ33MOvlkge9YxYpIyoN/8i7Cw0 vOMkjv5ONz3Rb9KWQJUFfLhLXy5Brmvr7Uq5kBvifKOMwgRgQjlUtXpucOoyJx6V8ocDBkn+LXQvjw q/Wk6CiY3L0mvlRycBEvI0Y0T7a0nI X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB As observed during review the pKVM support for saving host SVE state is broken if an asymmetric system has VLs larger than the maximum shared VL, fix this by discovering then using the maximum VL for allocations and using RDVL during the save/restore process. Signed-off-by: Mark Brown --- Mark Brown (4): arm64/fpsimd: Introduce __bit_to_vl() helper arm64/fpsimd: Discover maximum vector length implemented by any CPU KVM: arm64: Fix FFR offset calculation for pKVM host state save and restore KVM: arm64: Avoid underallocating storage for host SVE state arch/arm64/include/asm/fpsimd.h | 17 +++++++++++++++ arch/arm64/include/asm/kvm_host.h | 2 +- arch/arm64/include/asm/kvm_hyp.h | 3 ++- arch/arm64/include/asm/kvm_pkvm.h | 2 +- arch/arm64/kernel/fpsimd.c | 38 +++++++++++++++++++++++++++------ arch/arm64/kvm/hyp/fpsimd.S | 5 +++++ arch/arm64/kvm/hyp/include/hyp/switch.h | 2 +- arch/arm64/kvm/hyp/nvhe/hyp-main.c | 6 +++--- arch/arm64/kvm/hyp/nvhe/pkvm.c | 2 +- arch/arm64/kvm/reset.c | 6 +++--- 10 files changed, 65 insertions(+), 18 deletions(-) --- base-commit: afb91f5f8ad7af172d993a34fde1947892408f53 change-id: 20240604-kvm-arm64-fix-pkvm-sve-vl-13cd71fd7db0 Best regards, -- Mark Brown