Received: by 2002:ab2:3c46:0:b0:1f5:f2ab:c469 with SMTP id x6csp184827lqf; Fri, 26 Apr 2024 03:51:22 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXFwd3nXw+T3PV83BAZpf3ardbP3P0zgEm2t0osp2wptzlU2+oFmi4bRb4GNefRfzb+PHmCruSBEAETYhXqDWlZQIWaNFLIPLfZ+Q+CJw== X-Google-Smtp-Source: AGHT+IE/FX1HjuKWVS5jVw00X83rw6jFtYcEZ8kDI22GbQ/eFd5AHI7DthbqCpbLiz/BOxGmIdj9 X-Received: by 2002:a17:906:138d:b0:a58:b5b8:5805 with SMTP id f13-20020a170906138d00b00a58b5b85805mr1754268ejc.39.1714128682543; Fri, 26 Apr 2024 03:51:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714128682; cv=pass; d=google.com; s=arc-20160816; b=DTOufFGNpU4gsgrQKZb2WSj/6AyiPcTQfySbPs/qIIsPmEwAzObn+ZzXyG7NirpbFw Nloido5FPkOhO0QRSc/KehHXrb8mEOnWRLqOREVl2D2EfKmf27Bu/OJwbUoBRuyq6kMp UFkM2x8t0m0VqkVTQAjBmInuba6DshLyPD1zwYNki2h/FA03FFpgPQ4/AoB2sdJYTOHD QmqzoBh/yAdmaQqK8PE6tryUnMvgnTGOqPwDyEQ3vAfrE86OmEq0s9eyyy0vkRcxvU3I TIw8f9Lxs30uhC972uQZzcTaQv9OOSiqdK24EICaMAwgc8rb5ssWjFy7bur0OEq7hTHV ZX+A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=AySb1TlhVPPrqTACK8fU1SzEo7gL7MLhlk77wlxrmQo=; fh=XlJn20KrK4EvaKvASa2pJrSx3qxe+3Pj5g/DwHp+dAQ=; b=bp5KtjycqgYAeO2iQIiEi5g7dXbfFA5UzvNbP91Ukl1DJVpNc2rmblKavYX77V5urP AQsmtVbA3Vy2Wzg+/RE8LttyJ4f8UetFaYhhNGYQ0PJKQyVBzy8F9hDN1v4I3Um48Atx JmuHp3Eyn6pNXlTJtTE8gD7OCWqJHzZwZLpdIugK2lHeb2EuLckFnsZQRG58MGhL6PSp jQnMtNmj6QHSIKybfs11FcpenuHV9ROnlOeVGk2nLjDgIQ/eR3qjsyZDM8kqnX2Av7oW 6myC49H5wxHw3o5oWabh4unx2cT9prU/WSqm+Wen48YSUAPXCxohrbe8Ed8ZR2fDBPjF jgVg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="Kd/aJxvM"; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-159903-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-159903-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id v4-20020a170906488400b00a58b017ff3fsi2037558ejq.731.2024.04.26.03.51.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Apr 2024 03:51:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-159903-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="Kd/aJxvM"; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-159903-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-159903-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 4727B1F221EA for ; Fri, 26 Apr 2024 10:51:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F313C145B09; Fri, 26 Apr 2024 10:50:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Kd/aJxvM" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 74FF6145327 for ; Fri, 26 Apr 2024 10:50:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714128604; cv=none; b=DsYgvFW4HjdcA80AL3IMEQDVcfva+9RlivJC2EB+IaHfG841IHNSAVfwTmqW89GdwMx+O3CtTBrXLt8hgndV5M0NYBkNef2MjZvM5ICc1O2Tbka7SAayCqPy3e1KLbHTjUvplLmOU02yUxWacCdxtcJPS+188zWggvkRhzJzXnc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714128604; c=relaxed/simple; bh=3TP2uHC4mQRfabmD1+dpyNDOj8vwZ4B4oSRmGaqT+Eo=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=spwFR8i4y6e40WQzjCOoueGmd2c8XARU9y5Gdiceg0X7qaqaPEY9TYnBlV8bJDJtmvYXPXYkH3MAa0NvAkGmbCi9lfDY0qseyGchAUOHQudV/Zxp8BFgjo9KPagLGpId1ufYig74xubWpNBtU9NI4XPu2GhibNVGN/DhsJj+ptA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Kd/aJxvM; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1714128601; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=AySb1TlhVPPrqTACK8fU1SzEo7gL7MLhlk77wlxrmQo=; b=Kd/aJxvMZhKIrBHzN7ysNiBpIeDku4M2bbzsMuMVW68G6vA2I8ux3r/lTmzR7Z8tP5Kvos ck8ZQE08+cUuPgyzK0+kc26g7D5xDJ75iOzt5zjNKXEiARzAL9pM7TH76pr1EuopU3lRl8 e5W9ITaWgjegAnLusJFT0AO3wrKIuVA= 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-540-jOSv7jo1Pl6NtXb8PjjIuQ-1; Fri, 26 Apr 2024 06:49:55 -0400 X-MC-Unique: jOSv7jo1Pl6NtXb8PjjIuQ-1 Received: by mail-oi1-f197.google.com with SMTP id 5614622812f47-3c613c1c51eso1887601b6e.3 for ; Fri, 26 Apr 2024 03:49:54 -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=KO7qA80BE+aBJzhsUkUI+nNlD59mFznmQLy0W2+8OsJ8vQGIVbKVZLUxVF3/rXTBxT 4r+C9szklWp8gVxCFI7BQiWhv2sYj1awHo8Xj3QxQGer0UZCmgicCzViSE8dqxwrOcMh TeBLNTOQbt3R+6sSHX57qWAA1lM9OZQuChEc/XOLP+7JrK2i2KR9L4CDFN0eTZY/CQN9 0axNfPRST3ABCgey3TDeTwihibZ07c0kRkitaRxioPTLslpWcwwKveq2Ake6l8RdtGwv wTBEx0PppFXa595PLVO8Ma01d+ul3wxZJO+C+suk/SceDbD/B1m9RERUa+NhJIsGJNr2 FzYw== X-Forwarded-Encrypted: i=1; AJvYcCW75arjxKt+EcSqS8YTqTLUVEjRqXwq9z//BN+lqOLwvk3Ip08zS7PBBvLZSqoM6rBu7PdbF4KfEQxDEx9UuVjIp0StffR3A4yA45uW X-Gm-Message-State: AOJu0YxbfF5XLJBCFiW5SRVWEmDWxPqsxy6VXGW055MQOiUERDeOEdnU 8isl6ca8JBO9VU5zARTHpp5p4uADSZ07zVt4IU2ieZSpZj4BzwoNQMIHqjieKxt5Ff9qo+a5LKN +u324+K/YMDmJmCsCBWGLJOD7/kjBIASnOghbMJtjeLxwBOb1jzOFgBGrXftYdg== X-Received: by 2002:a05:6808:bc8:b0:3c6:f7b1:b228 with SMTP id o8-20020a0568080bc800b003c6f7b1b228mr2723694oik.31.1714128594301; Fri, 26 Apr 2024 03:49:54 -0700 (PDT) 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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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(-) -- 2.42.0