From patchwork Fri Apr 26 10:49:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Ott X-Patchwork-Id: 13644618 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 D6AA8C04FFE for ; Fri, 26 Apr 2024 10:50:40 +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=1ZR/FvYcSqyeG9taQRFfp/pP++465s0nm7WrFReIlIM=; b=nnR1GRSSZ7qIvw KzYkoa+b0b06PJUvFf3mxYPBHMpuf75+h6wK0hxZCoTlbiKkRht4XRydAn4SyZxbC8W17ffi/jDWw nS3Tx1Y7rmBdWvHQWYwecBSKt2JIwvcGVzo0yaOPd/czWpf236+LaE+jBlb8Gh5AuHYsHFzqb20MA G4GSrzLg+duLsstBh9Bpd3Y5vo4+MT/pHfaHxGdVdml6VIEs2O5l7UJQvHjFGVkhozg+ec3rNw1dp rZEOSdGkdSZNEkhGDPRE5puJa917b+sGIpO3xn5k4LEItcRYl35efQJH7JMGJzy7Yv5Ok4jxPqjsE nrZEGTx+NevRqWzrtd+Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s0J9x-0000000CDVb-3GNY; Fri, 26 Apr 2024 10:50:29 +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 1s0J9g-0000000CDEg-1Tb4 for linux-arm-kernel@lists.infradead.org; Fri, 26 Apr 2024 10:50:15 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1714128596; 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=AySb1TlhVPPrqTACK8fU1SzEo7gL7MLhlk77wlxrmQo=; b=YTvViA2s24UEmr1Nct7zx/TTqq6Sw5L3RgDe++ea3bDT9hLoGD/sso1F3nfTdXKGsAS91C A0f80Lw4JuDaZTnEjFZ0+Znqy50ttREFHz6SomAorEI3g3OGrmT8Mgqn7cDQ8a0i4U2UpO aotd2eJeREOoUf19lF5W4xpytDef1yc= Received: from mail-oi1-f197.google.com (mail-oi1-f197.google.com [209.85.167.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-447-MvOkYfe-PjSZGKos5eZH2w-1; Fri, 26 Apr 2024 06:49:55 -0400 X-MC-Unique: MvOkYfe-PjSZGKos5eZH2w-1 Received: by mail-oi1-f197.google.com with SMTP id 5614622812f47-3c84e8c42a8so1469915b6e.2 for ; Fri, 26 Apr 2024 03:49:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714128594; x=1714733394; 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=AySb1TlhVPPrqTACK8fU1SzEo7gL7MLhlk77wlxrmQo=; b=N1hjXCr8L4lkE9OWjwy7rzZMI/ZA4B4a0JlYEuQA99CepS8FRRipdeDVdbXd3JxxBJ RVwieoqOXmKSrdKwenMoPoAzJbkCJt7NylKzd5Bh9UZKxAVzKsOaALPskgopcxIumJjk rb6iJef+cE+2ovZGlkVwvp0kW6aRsueFyYU2/sVzLPn6kqRzXwTJ1PSXnYq5OCNezBmV I2TYuX/UQURBZ/gjhFkMOLQ3Xqs6m+1DF3ingNLGXZJaD/o/phgye1Np3+1ACU984NDE a8Nx0zQ/Jz5j8XxSDlCs82A3I0GrQE5NHJEiR6Z4wFrcRI8d38+hHzrB70rC+oJD7KJX bowQ== X-Gm-Message-State: AOJu0YyWAzOfsF/BnVm/DAGMQgDp7CcOXlRc16x/F4UxYXuqbmCbHhAS H1KEQy80z8iK1V2Y++fFXMNhnQVTvgxz2h3qIMGiBifb2ckVzB2Y9EOXm6K2YH6hpM/6TVHXU/B 00UX5dzqpm+6Bx+K+GQtPLB4UiiWh1tkszy3Rm8eul5faed9IBnQGrBRXZjFveXyTkDjh/Ytx1A joXTVeO8m1aH2cpSX2DT0haPf1STAF560VjZmjYPzjclht6lNjPXpsiw== X-Received: by 2002:a05:6808:bc8:b0:3c6:f7b1:b228 with SMTP id o8-20020a0568080bc800b003c6f7b1b228mr2723698oik.31.1714128594403; Fri, 26 Apr 2024 03:49:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEZsGfT69zsmTCVgTcj+/En2dvpkEVqYiuQXZdoAX6RGBoDOOIyO2jwTtLnAHh1VuafDtHvkA== X-Received: by 2002:a05:6808:bc8:b0:3c6:f7b1:b228 with SMTP id o8-20020a0568080bc800b003c6f7b1b228mr2723673oik.31.1714128593932; Fri, 26 Apr 2024 03:49:53 -0700 (PDT) Received: from rh.redhat.com (p200300c93f4cc600a5cdf10de606b5e2.dip0.t-ipconnect.de. [2003:c9:3f4c:c600:a5cd:f10d:e606:b5e2]) by smtp.gmail.com with ESMTPSA id vv26-20020a05620a563a00b007907b57aa1fsm3888019qkn.12.2024.04.26.03.49.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Apr 2024 03:49:53 -0700 (PDT) From: Sebastian Ott To: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org Cc: Marc Zyngier , Oliver Upton , James Morse , Suzuki K Poulose , Catalin Marinas , Will Deacon Subject: [PATCH v2 0/6] KVM: arm64: emulation for CTR_EL0 Date: Fri, 26 Apr 2024 12:49:44 +0200 Message-ID: <20240426104950.7382-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-20240426_035012_658350_8629F58B X-CRM114-Status: GOOD ( 13.48 ) 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. CTR_EL0 is currently marked as invariant and migrating a VM between those 2 machines using qemu fails. Changes RFC [0] -> V1 [1]: * store the emulated value per VM and not per VCPU * allow to change more values than just the DIC bit * only trap guest access to that reg when needed * make sure to not present the guest with an inconsistent register set Changes V1 -> V2: * implemented Marc's suggestion for keeping registers consistent while not breaking userspace ABI / expectations (I hope correctly this time) * keep the shadowed value valid at all time * unify the code to setup traps Note: * in order to switch off CTR_EL0.IDC userspace first has to set up CLIDR_EL1 accordingly * reading CCSIDR before and after changing the cache size in CTR_EL0 could result in different values (but only if CCSIDR was not changed from the generated value) * I'll prepare a testcase for the next revision Thanks, Sebastian [0]: https://lore.kernel.org/all/20240318111636.10613-1-sebott@redhat.com/T/ [1]: https://lore.kernel.org/lkml/20240405120108.11844-1-sebott@redhat.com/T/ Sebastian Ott (6): KVM: arm64: change return value in arm64_check_features() KVM: arm64: unify trap setup code KVM: arm64: maintain per VM value for CTR_EL0 KVM: arm64: add emulation for CTR_EL0 register KVM: arm64: show writable masks for feature registers KVM: arm64: rename functions for invariant sys regs arch/arm64/include/asm/kvm_emulate.h | 37 ----- arch/arm64/include/asm/kvm_host.h | 4 +- arch/arm64/kvm/arm.c | 3 +- arch/arm64/kvm/sys_regs.c | 225 ++++++++++++++++++++------- 4 files changed, 173 insertions(+), 96 deletions(-)