Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp960721lqj; Mon, 3 Jun 2024 06:23:08 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU5m3fXeb9SDknODI5C1vbTEC0dCX4OuJILAiGvd2gWGg8nRiG8B3bzUwlpupg7sJxb8YjVMpBeGqSsR+njyhhRsQyF3Jp9Qjo3SK2xAw== X-Google-Smtp-Source: AGHT+IFiEaut5P/i4+cbdhmqXfnG34/RhxNVgLGURmMfG3Q2AUTYWUXwwk1iXc5I/nFMW5s9MmII X-Received: by 2002:a17:90a:fe94:b0:2bd:801f:dabd with SMTP id 98e67ed59e1d1-2c1c43deffbmr12475687a91.3.1717420987670; Mon, 03 Jun 2024 06:23:07 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717420987; cv=pass; d=google.com; s=arc-20160816; b=AaSnXqudshuBtsFMAsTQpDl/Mr6ruG6hUlt7/36FSTWsqdPGFk+JdOuQrEpYYfjRED 4vjKeI/lUL69RS07gwpn7bKGzXdzZlYieeKyjF9GmHmthxlxeOiK+LKB02Vaw6/lsBjg 7IlnhpdxqjLhd9t3Us/OvJTDgUuWevG1alegXUcyx8SayWuWwyTdSp4MhVH2nJPHjxTA cqaa3DVZYurkktFqMMKOfrUfPhum7b7Pgz8bMsuBNlFPSdJ+TBAg/A11EE9cMRBWjrHf oo4hE62k+7WXJ9o99oaH0Y+Mtjgt6UCO6xuKQzk5SY/wGrsH+z/jWS/gF3MWvxR8F+CG RuPA== 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=UuAz2osHy9RXhO+JIQRbzgjz7RRp47pq6Qz525G205E=; fh=hzqGMlDChfX6nHQbAMohKlN01RPdIffA+9lYnexRF+M=; b=lh1vFcT3ufI7GVDAtLf7VUJWZtjf57BuntABGqUfjOUh4vUxa8xXedwv0FseOAxTW2 IkGRoSvm8eMga/CJhzX0VwWebHK+VLvZkrQWgOrF0vueqcmzcW7zILAltipUPWAeFNex lD2JWc+XEXXTI9LqWZ4mc8hK0/XrelpqHYsDgQzCyuPHwtJQQRqSO1xK9U2GBhGvInnH FVANkSDhA2Nk7BNCfSsGGAb6Hs57VKRLrvepBkBLbac11WiatoPrCG+Sf2lCQA7rCR5M lF9bVngJqthGgzfeRPkR0pi8uuqre0Izr2+iSiQZwtedn5y/aZK3hnomObDNBW208MEk Emfw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ObCrqA9A; 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-199174-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199174-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2c1a777aae0si188999a91.40.2024.06.03.06.23.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jun 2024 06:23:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-199174-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ObCrqA9A; 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-199174-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199174-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 04AFEB2616C for ; Mon, 3 Jun 2024 13:05:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1BF3412C484; Mon, 3 Jun 2024 13:05:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ObCrqA9A" 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 9C8FE12BE81 for ; Mon, 3 Jun 2024 13:05:16 +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=1717419918; cv=none; b=fTmvFtH/6/Yshn8Z3rc4lgp318A3umj6bx7r8An4TOxJuYCY8jnSjZPaGACf8LrQehUyl6lst/lZ67OKLP88+Qn22dU/jkfOuu8/7QMKcQULU6UF3syaG434ZqtKXA3Oo3524FzbuOe8BwldFYgej+zR+wH9dS5gZrw8WHxza7g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717419918; c=relaxed/simple; bh=ZmgshMwK/h8YuHfgrohZ07iPt7cMhx0SOYi8UE3BetI=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=S9ysbtTrErrrBxxW7PsFAZwNtHzQ//CuwOCg32ms3QMVpXL6p9sSGAK6Wtn9gY8HaI62FH9PXKGhUawdwSh27+a99TJH2yfcFO+Gs7cJcTFMfKS2jNT6jGrTNXc54Sc7c+HvBsAtUR9nIeX4gouc/aahO8RpBNV0dw5/QI/2ga4= 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=ObCrqA9A; 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=1717419915; 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=UuAz2osHy9RXhO+JIQRbzgjz7RRp47pq6Qz525G205E=; b=ObCrqA9AsWejVDBHVyDcHFGH1FRHe/yAKlLAnYWNWiPB1tHSUvbLE/avNlsD5FgBZBI32n acHQWAegOzM91hrG5yRygY2nPLHAVRXbWb5uPaDCrLyhQQNl4VivXbi8tmf+AREf/KFVC0 TBfrreFhbnHTYs5liH9IWwluHZHw/hs= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-82-VgeSge6BP3m5xX7zqEu1rg-1; Mon, 03 Jun 2024 09:05:14 -0400 X-MC-Unique: VgeSge6BP3m5xX7zqEu1rg-1 Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-794f5424490so538411285a.0 for ; Mon, 03 Jun 2024 06:05:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717419914; x=1718024714; 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=UuAz2osHy9RXhO+JIQRbzgjz7RRp47pq6Qz525G205E=; b=qALsex1qOPoQktJJnxN55aNAu7pyGYxghAyGtRNdvZO2ACauMPoASg4sB6BUcbSd8l 45jfX6Uzgrm2OhwWu7NiMkkgg7LvGy2ecro+ziihVYX7b+Dc6YkbQbvF6Fw9Pwj3oMwh 0usngt7rRKk897c+vuZaPyy9LnqpHmSUp7dMDwKMi8GY7B7M6KqKvdUABaqXdTcrVjCV ub7Ed4a/UKvrqycqKHVejxW7f6V4NwPyqGzrUpPVk2aXhusYhmGpkk/S2BsRLJsadNqp lPJzrBeQ2YJKfKjUvwxpgXHs95XLPtHPNL55Kwz7ac7zE+3ULzt59rC/Ev9eNWbR33Dx e8Kw== X-Forwarded-Encrypted: i=1; AJvYcCUEJeMdGI/c3lEDmU+olEw4LkVXqceZOoTeLUDCpyktciDI3dTirJciZLv9xyUQT47/bGXK0wYe8WTCx0wJ/KZ/Z1ZGUyK5J2GfHRrw X-Gm-Message-State: AOJu0YwFQI2nkn0V4DXtqyeUnjeP8HxaDWtRK3Z7Wt4PCqM0hD5u/X/W 6omX2mTwKnq+THr/HdEDISAalphPHupmqM1xpUVM5fKicM5bj35G1MmOOZUs0Ax/yjfnK3kqO4i lsfOM5nEzLTW5IkO4D5L5R83i55MIG5DOGsItppdaiu5/c2FYz3ahI49xzM3Ylw== X-Received: by 2002:a05:6214:4402:b0:6af:bada:7dc7 with SMTP id 6a1803df08f44-6afbada7ffamr49263936d6.19.1717419913772; Mon, 03 Jun 2024 06:05:13 -0700 (PDT) X-Received: by 2002:a05:6214:4402:b0:6af:bada:7dc7 with SMTP id 6a1803df08f44-6afbada7ffamr49263006d6.19.1717419912865; Mon, 03 Jun 2024 06:05:12 -0700 (PDT) Received: from rh.redhat.com (p200300c93f02d1004c157eb0f018dd01.dip0.t-ipconnect.de. [2003:c9:3f02:d100:4c15:7eb0:f018:dd01]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6ae4b4179f4sm30558826d6.113.2024.06.03.06.05.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jun 2024 06:05:12 -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 , Shaoqin Huang , Eric Auger Subject: [PATCH v4 0/6] KVM: arm64: emulation for CTR_EL0 Date: Mon, 3 Jun 2024 15:05:01 +0200 Message-ID: <20240603130507.17597-1-sebott@redhat.com> X-Mailer: git-send-email 2.45.1 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 [2]: * 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 Changes V2 -> V3 [3]: * rebased to kvm-arm-next (to include Olivers idreg fixes) * fixed VM ops trapping for non-FWB CPUs * fixed writable mask for CLIDR_EL1 * re-added manual ctr validation (using arm64_check_features() had a side effect with the way .reset is working for these registers) * added a testcase Changes V3 -> V4: * incorporated feedback from Shaoqin and Eric 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/ [2]: https://lore.kernel.org/lkml/20240426104950.7382-1-sebott@redhat.com/T/ [3]: https://lore.kernel.org/lkml/20240514072252.5657-1-sebott@redhat.com/T/ Sebastian Ott (6): KVM: arm64: unify code to prepare traps 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 KVM: selftests: arm64: Test writes to CTR_EL0 arch/arm64/include/asm/kvm_emulate.h | 40 +--- arch/arm64/include/asm/kvm_host.h | 4 +- arch/arm64/kvm/arm.c | 2 +- arch/arm64/kvm/sys_regs.c | 214 ++++++++++++++---- .../selftests/kvm/aarch64/set_id_regs.c | 16 ++ 5 files changed, 201 insertions(+), 75 deletions(-) -- 2.42.0