From patchwork Sun Dec 18 05:14:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 13075974 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 166D0C4167B for ; Sun, 18 Dec 2022 05:16:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=Co4Vug7fOiOF2hwQsNxjpK4E3XPKfSfTP9cBk8jCahc=; b=hxzgDOlYmV7Qqy E52s5zrBMWzrZXPjX/4kXAM8t9KDUYMzTZT3+Cd8fazZv3Hw3esm1Ehi2/CkkHS89z1cBhaoSeI5F iADkaEQbLLdJq/9SeB7QVCzw6N2oLkV6ZrqauZdYgrp2diWmXvLz7tJ39EQljqTSPqSXr8UFJ1HXR Z4pNAXZpiyIvnsyNZGf9ezHPGkaPQlrK4+KnlLKgJjUf5wgRyJWYoGrUT4GrkqDHp1Go/QQ4Gfsg5 velw+grHJfXgmSbgdGLg9MsBNM3IWOUjCOX6IoyJCk/ROFvPYUxuAemYrUasCzYXxvvyUgEqDq/O4 m7xLlpHQZeCMkxXOZ12g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p6m1N-00FuO5-Ie; Sun, 18 Dec 2022 05:15:33 +0000 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1p6m1G-00FuHz-Sq for linux-arm-kernel@lists.infradead.org; Sun, 18 Dec 2022 05:15:28 +0000 Received: by mail-pj1-x102a.google.com with SMTP id w4-20020a17090ac98400b002186f5d7a4cso10014375pjt.0 for ; Sat, 17 Dec 2022 21:15:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=a01G1GBaf3qfiSutprsFR/TlqOiwESaNiFiCPW34lhQ=; b=oB2m/VIEAkS9xOaITyE3rjE56r6CApd8uv6/I9Uhzf8pGv9vmJR578c5JqGMjoKvPv kRaPQEyoEv/UxuTchSJGFAhseLU8GEBHWCYoQenv0Ni/ERulgVgmbY3R/CwgWJw/TvAs 3IeonmoVwK5kmEVznc8OofYBZSw1es2YvP7mL6RU21/0ABA/Kh6iBYlEl6MlbLsjVe4X ALHKRtXC/iDcupj1w/c56rFgGtEO3dQpCE4BWpSytHZIad5dgzuxbns1fNb3nFkpVaw0 ts9lgWdtWxzOk2YhyxanXAGFYk4O0Rk9MCFkzxjA6qSrJb/6shjAA5V82VzCfyKPQ4Og HTbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=a01G1GBaf3qfiSutprsFR/TlqOiwESaNiFiCPW34lhQ=; b=gJTACiE+ASRLy5bvga5iNSsEmxPBq1qU3OgyQ9wllLJJ5bEfgFeBH+djWHOSWyzW1n tgyi2jbUgdjUYPKCRfejYXj1I9oadRXqTwWAMwOBkKLGTth73EKhxELilCepznz+bEXI /NZzx/8J17PW4c2xy6MjrYh867eN4TNG19ggWY7KJaLl49pvYLinoWfEyDHXsGGiU0f4 lEZoop4j0ubNkxVBRMYHEIpbgOCjDqjhhrpj6zLsUPjSWthVtULSxrMK4i81Aq/c6RRf yI0R06yPEUVv+2mnRn4UskJfG9fpTSUIHRR7i/uY2Uezr5+bL1uinnRWasiz5WdG1WWk nJDg== X-Gm-Message-State: ANoB5pkGAEIY3GHhxAiV4sWfM3VYNPKU4ookKhmWlNASZMTOKVlDGAj0 s+im6lJjwzkMwJASAvv9KQNbvA== X-Google-Smtp-Source: AA0mqf72YV5edT4kAgOZXEWT3kE8W12UBWocuqS2BFj9Nm3zqofKc8b75dDfMhucuQYOpxQGxpjPjQ== X-Received: by 2002:a17:90b:4a8c:b0:219:e763:1d21 with SMTP id lp12-20020a17090b4a8c00b00219e7631d21mr39250867pjb.5.1671340524491; Sat, 17 Dec 2022 21:15:24 -0800 (PST) Received: from fedora.flets-east.jp ([2400:4050:c360:8200:8ae8:3c4:c0da:7419]) by smtp.gmail.com with ESMTPSA id b1-20020a17090a6ac100b002139459e121sm7002417pjm.27.2022.12.17.21.15.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Dec 2022 21:15:23 -0800 (PST) From: Akihiko Odaki To: Cc: Marc Zyngier , linux-kernel@vger.kernel.org, kvmarm@lists.linux.dev, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, Mathieu Poirier , Oliver Upton , Suzuki K Poulose , Alexandru Elisei , James Morse , Will Deacon , Catalin Marinas , asahi@lists.linux.dev, Alyssa Rosenzweig , Sven Peter , Hector Martin , Akihiko Odaki Subject: [PATCH v3 0/7] KVM: arm64: Normalize cache configuration Date: Sun, 18 Dec 2022 14:14:05 +0900 Message-Id: <20221218051412.384657-1-akihiko.odaki@daynix.com> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221217_211527_201441_06D8EE8D X-CRM114-Status: UNSURE ( 9.62 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Before this change, the cache configuration of the physical CPU was exposed to vcpus. This is problematic because the cache configuration a vcpu sees varies when it migrates between vcpus with different cache configurations. Fabricate cache configuration from the sanitized value, which holds the CTR_EL0 value the userspace sees regardless of which physical CPU it resides on. V2 -> V3: - Corrected message for patch "Normalize cache configuration" - Split patch "Normalize cache configuration" - Added handling for CSSELR_EL1.TnD - Added code to ignore RES0 in CSSELR_EL1 - Replaced arm64_ftr_reg_ctrel0.sys_val with read_sanitised_ftr_reg(SYS_CTR_EL0) - Fixed vcpu->arch.ccsidr initialziation - Added CCSIDR_EL1 sanitization - Added FWB check - Added a comment for CACHE_TYPE_SEPARATE - Added MTE tag cache creation code for CLIDR_EL1 fabrication - Removed CLIDR_EL1 reset code for reset caused by guest - Added a comment for CCSIDR2 V2: https://lore.kernel.org/lkml/20221211051700.275761-2-akihiko.odaki@daynix.com/ V1: https://lore.kernel.org/lkml/525ff263-90b3-5b12-da31-171b09f9ad1b@daynix.com/ Akihiko Odaki (7): arm64/sysreg: Convert CCSIDR_EL1 to automatic generation arm64/sysreg: Add CCSIDR2_EL1 arm64/cache: Move CLIDR macro definitions KVM: arm64: Always set HCR_TID2 KVM: arm64: Allow user to set CCSIDR_EL1 KVM: arm64: Mask FEAT_CCIDX KVM: arm64: Normalize cache configuration arch/arm64/include/asm/cache.h | 9 + arch/arm64/include/asm/kvm_arm.h | 3 +- arch/arm64/include/asm/kvm_emulate.h | 4 - arch/arm64/include/asm/kvm_host.h | 6 +- arch/arm64/include/asm/sysreg.h | 1 - arch/arm64/kernel/cacheinfo.c | 5 - arch/arm64/kvm/hyp/include/hyp/sysreg-sr.h | 2 - arch/arm64/kvm/reset.c | 1 + arch/arm64/kvm/sys_regs.c | 246 +++++++++++++-------- arch/arm64/tools/sysreg | 16 ++ 10 files changed, 182 insertions(+), 111 deletions(-)