From patchwork Thu Dec 1 10:49:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 13061208 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 06DB4C4321E for ; Thu, 1 Dec 2022 10:51:10 +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=Zol/WjIuR7Ni9/AO0Ny2Cg6XPW9BDG8D+aqOQpOxCzU=; b=wVi4XBUBf1Ae6E jI0gkY+Jj6dvKJQXNFcodElSYh5Qsi4faKRkePivVQlyWV5pSRX2+faKq2KmU1c+D8TFTdG/Pq/M6 TKTKU8cDQpP2htoxWHE6DoVpcnU6y0Hr9SxBsVb4zSxCe7s9NImSDRBUFYxQRF1cpKnU4wl4Ams8n 5yZQiTqzUnC/K0nE9kHYKAEmmjtsYkh3S00KLrm6cr6RpldTFf9BPvtydvcZdHN6fOGONM65XNagk q7atN9qVRK85PXzQ02Yjfub7nwcLiQNTajl9pCATQCKG127LEknmrG4jyY9JXGDPJlt3AzaHeU2Qy ISKmBCtMwJE07F8QHNmQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p0h8a-006qOj-Q5; Thu, 01 Dec 2022 10:49:52 +0000 Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1p0h8X-006qKa-Ea for linux-arm-kernel@lists.infradead.org; Thu, 01 Dec 2022 10:49:50 +0000 Received: by mail-pf1-x432.google.com with SMTP id 21so1505603pfw.4 for ; Thu, 01 Dec 2022 02:49:47 -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=foBGF6JlnonEt7u87TDzA6BdrpBeBHRT3WfaCgQwD4w=; b=pGFrHYoSXyP+05btXeBT3GDPA3BBMxmoFjzQZdLLbgcGtRtd7Y/ed5g89sJ1Ko2BPl w/8U2Gtv0tPTKbIoyyXc0HC34rPREN8tpEVZ/Qtoy8EeMjUkcOed+O4vgW6MMT3hG2Tb tO9d9Tl7iu01SE4eUZGMehhVYLEiufve+6A3CwtlCYfgpP/KxK/0YZh41SA3Qd/K0L0p nljgnw7gJjidBiRqpmEM674grrj/teo9cmJEC8loX80WVe6FUFnf0OGBf/zgJL2lXACi RkyW+dL8owebIelG/XFn8Kfi64VfgOBe21NgfHGMBM72tOVxpHAQkbIbXMQ3GtPimpw/ ZP5Q== 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=foBGF6JlnonEt7u87TDzA6BdrpBeBHRT3WfaCgQwD4w=; b=jlc/vViPrz0p1EY5gIkSUr2hyraOIrgFTi1lYOiMe437Kbcdtv88YaEUy88ApvCPIc n34s4wkUgP4Hk63FSIluLLzSvAa01KB4AU4Y9uzJSjYtnsiXxw93u1idQ08BZ9/Wu0xa roZLSDTZ4H3ijqaPMy2gOMmpJuCPhMr0yUyaJsy8Nd/PnaChPUCR8QPrLOk1AHygqhRu 4yQ1oRV6kLqQ8tqOKAa/2y5a7iwYOxri9A2Vg6rs5g+ippF32KD/qE+p5HU1aRPJnnFx mhetBDw5E8XT46cw638yVpxReGWH7ez+Rk3VRdMgI00KBmOK/6P9NQ1yP2fxTL9Jr/sj Flnw== X-Gm-Message-State: ANoB5plJoRGa8pmGFf+2yr4xfP+d4k6bp/n05miDo8E9/enxI+9HZ8Fz mZsXH3z0Q9w7md7kFqHCww2f2A== X-Google-Smtp-Source: AA0mqf6Cyu7laoCbi5JoSZv0gkqjvpvrXeXiVPp6Vj2NLBpsceZWkQJBNxO9yJFLr0IOOo439dEXsQ== X-Received: by 2002:a63:310:0:b0:478:7e02:fa11 with SMTP id 16-20020a630310000000b004787e02fa11mr25577pgd.222.1669891786574; Thu, 01 Dec 2022 02:49:46 -0800 (PST) Received: from fedora.flets-east.jp ([2400:4050:c360:8200:8ae8:3c4:c0da:7419]) by smtp.gmail.com with ESMTPSA id 4-20020a630804000000b004785a63b44bsm2320580pgi.43.2022.12.01.02.49.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Dec 2022 02:49:46 -0800 (PST) From: Akihiko Odaki To: Cc: 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 , Marc Zyngier , Will Deacon , Catalin Marinas , asahi@lists.linux.dev, Alyssa Rosenzweig , Sven Peter , Hector Martin , Akihiko Odaki Subject: [PATCH 0/3] KVM: arm64: Handle CCSIDR associativity mismatches Date: Thu, 1 Dec 2022 19:49:11 +0900 Message-Id: <20221201104914.28944-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-20221201_024949_730690_D2961BFC X-CRM114-Status: UNSURE ( 9.11 ) 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 M2 MacBook Air has mismatched CCSIDR associativity bits, which makes the bits a KVM vCPU sees inconsistent when migrating. It also makes QEMU fail restoring the vCPU registers because QEMU saves and restores all of the registers including CCSIDRs, and if the vCPU migrated among physical CPUs between saving and restoring, it tries to restore CCSIDR values that mismatch with the current physical CPU, which causes EFAULT. Trap CCSIDRs if there are CCSIDR value msimatches, and override the associativity bits when handling the trap. Akihiko Odaki (3): KVM: arm64: Make CCSIDRs consistent arm64: errata: Check for mismatched cache associativity KVM: arm64: Handle CCSIDR associativity mismatches arch/arm64/include/asm/cache.h | 3 ++ arch/arm64/include/asm/cpu.h | 1 + arch/arm64/include/asm/cpufeature.h | 8 +++++ arch/arm64/include/asm/kvm_emulate.h | 10 ++++-- arch/arm64/include/asm/sysreg.h | 7 ++++ arch/arm64/kernel/cacheinfo.c | 4 +-- arch/arm64/kernel/cpu_errata.c | 52 ++++++++++++++++++++++++++++ arch/arm64/kernel/cpufeature.c | 4 +++ arch/arm64/kernel/cpuinfo.c | 30 ++++++++++++++++ arch/arm64/kvm/sys_regs.c | 50 ++++++++++++++------------ arch/arm64/tools/cpucaps | 1 + 11 files changed, 144 insertions(+), 26 deletions(-) Reported-by: Akihiko Odaki Signed-off-by: Marc Zyngier