From patchwork Mon Mar 18 11:16:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Ott X-Patchwork-Id: 13595279 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 AEE5AC54E5D for ; Mon, 18 Mar 2024 11:18:58 +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=A6ZCxtxmYvHHIByzSlYX33crOHKxrNq2sf7YO881PN4=; b=QBxipzKX8EOuIU dLYbwGFDhLHrBo6iduK6JBpX4gPleQ7n+qu57RJo31eVP1fScMJwJX0FNlx4P6b9e5IlX2c1u9rsU TkFcz3LV6Upl+IWsntkh7toYSxihy+oNgUziZ7POLvYhCO6p6bRBLB9lsd60JlWbl1ae3eT+qz9EW lp8/aUTMx4MibrS9aRzO9V5cUMiJZQQfdsr/aZ1WuLoZgyTJm4wM4o4vG0IXcLAbk1WF97uS5zwG1 wy3L80ODx3xvVWklOBJ30nJ+b8CN15Hm/zLdpDNSZdmX1IcEk1OLce4QK4mGFpTEvwZ2sOVgplfQM p/X74Ob+9Jbpjxe6xWRw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rmB0v-00000008K5S-2dTh; Mon, 18 Mar 2024 11:18:45 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rmB0h-00000008JzN-3uCv for linux-arm-kernel@lists.infradead.org; Mon, 18 Mar 2024 11:18:41 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710760710; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=vagtwvYYA13WoajKWFPPjPn5TISS7rZo1ooajXpkntY=; b=ZM618TnQ+0E+3f059ls3cmJQ1uKfg6f36yYMAtQHQ00ncIIPGTlqUltx5/9Uwm9S7+MSwy frGfGVjvbbEGZKb4IeJ46U2jGky0sf3VIbXMBLSyj8zMnGe4rVUx3D/0hG+BT0hnHpLd+S P45lTyHiVkQqBZcz0WF1JDY0ikhVjNc= Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-177-ALH_mIfOMmWM3BXCl6aaSg-1; Mon, 18 Mar 2024 07:16:43 -0400 X-MC-Unique: ALH_mIfOMmWM3BXCl6aaSg-1 Received: by mail-qt1-f200.google.com with SMTP id d75a77b69052e-42ef6c2e84cso36693741cf.1 for ; Mon, 18 Mar 2024 04:16:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710760602; x=1711365402; 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=vagtwvYYA13WoajKWFPPjPn5TISS7rZo1ooajXpkntY=; b=LCzT/FyzhY4UYaUfuupZMWZDMHWzG+JP/KwTQZq0/2MIIy98sqaew3mzhwbP9WyAmA Nd0LscZ3jTfPyx1VcqsDMR/Yzt9dqX5Y0lSiq0Lyp8Z4zAzoCDr4pvo0V434WzOHBGEJ KmFdJI+UPvUt4tpmn44jsOH+UXTrKnb+EYdZQvvGNkNlhANLzwNmEo4hQ1yeR8EuM9pD x6WaECJWeO/QOcOxQ5RXmtJTgVttEjWNHlIniJYQo0Y6zVzUpI8+6cfzWoKE33UGWQMM xUstWJipxTiHN1slk5CWzqZZDABvLQpOAsgtov3sGQDGw4BWFHF92FIRSWGdwJFSXJpn Q9tg== X-Gm-Message-State: AOJu0YxUpMGzzPz+hj1mKnDevlxGwNWqJixGVfUxsC2GtBmg9Z1N1kiW 8V1XypruTTeog1XMBpSMY/WlL58YoVTd5dQpN1QKigN4+BH34XGWmGywn+wtyruQXIq0n0UKnCH eWRoUohKkQv7hKP6TcOQ9EhhcA5k+OKkAyzTCr2Z8qW3NoyVa9aDIc/o5coleBKOz852ItnnFYf jPO8X929n5Q1cpXPQAlbQlRI/JA1zMHluDuFm213QuPNavr+d3017nIQ== X-Received: by 2002:ac8:5c89:0:b0:430:d4cd:ebc9 with SMTP id r9-20020ac85c89000000b00430d4cdebc9mr1816699qta.34.1710760601682; Mon, 18 Mar 2024 04:16:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGbRXbj4LfBuk+Qu6DKJX/Up/vokHZN8mOjmPfqjEOLqapsxwo47asIqG6hFcBxJsLk6CalEg== X-Received: by 2002:ac8:5c89:0:b0:430:d4cd:ebc9 with SMTP id r9-20020ac85c89000000b00430d4cdebc9mr1816680qta.34.1710760601160; Mon, 18 Mar 2024 04:16:41 -0700 (PDT) Received: from rh.redhat.com (p200300c93f079e00cac8703672d98936.dip0.t-ipconnect.de. [2003:c9:3f07:9e00:cac8:7036:72d9:8936]) by smtp.gmail.com with ESMTPSA id ew5-20020a05622a514500b00430c8b87b46sm1832001qtb.6.2024.03.18.04.16.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Mar 2024 04:16:40 -0700 (PDT) From: Sebastian Ott To: linux-arm-kernel@lists.infradead.org Cc: Marc Zyngier , Oliver Upton Subject: [RFC] [PATCH 0/4] KVM: arm64: emulation for CTR_EL0 Date: Mon, 18 Mar 2024 12:16:32 +0100 Message-ID: <20240318111636.10613-1-sebott@redhat.com> X-Mailer: git-send-email 2.44.0 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240318_041832_794347_FD8638AA X-CRM114-Status: GOOD ( 16.16 ) 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 Hej folks, I'm looking into supporting migration between 2 Ampere Altra (Max) machines (using Neoverse-N1). They are almost identical regarding their feature id register state except for CTR_EL0.DIC which is set on one machine but not the other. For a complete picture it's worth noting that the machine with CTR_EL0.DIC = 1 also suffers from erratum 1542419 meaning for userspace we trap the access and fake DIC=0. A KVM guest still sees the original host value for that register (I assume that this is intentional so that a guest OS can apply its own workaround to the erratum). Anyway, CTR_EL0 is currently marked as invariant and migrating a VM between those 2 machines using qemu fails. With the patches below guest access to CTR_EL0 is emulated and CTR_EL0.DIC can be disabled using KVM_SET_ONE_REG. I'm sending this as an RFC since I likely missed something obvious and there's still stuff that needs improving - e.g. I didn't look into FGT. The last patch adds a tool to dump the KVM register state together with the writable masks - not sure if that's helpful to others but I've used this to compare the register state between different machines (abusing kvm selftests for this is probably not the best idea - I just wanted to use the neat helpers they provide). Thanks, Sebastian Sebastian Ott (4): KVM: arm64: add emulation for CTR_EL0 register KVM: arm64: ensure guest access to CTR_EL0 is trapped KVM: arm64: show writable masks for feature registers KVM: selftests: aarch64: add tool to dump registers arch/arm64/include/asm/kvm_emulate.h | 7 +- arch/arm64/kvm/sys_regs.c | 63 ++++++++++------ tools/testing/selftests/kvm/Makefile | 1 + .../testing/selftests/kvm/aarch64/dump_regs.c | 72 +++++++++++++++++++ 4 files changed, 114 insertions(+), 29 deletions(-) create mode 100644 tools/testing/selftests/kvm/aarch64/dump_regs.c