All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oliver Upton <oliver.upton@linux.dev>
To: kvmarm@lists.cs.columbia.edu
Cc: kvm@vger.kernel.org, maz@kernel.org, will@kernel.org,
	linux-arm-kernel@lists.infradead.org
Subject: [PATCH 0/6] KVM: arm64: Treat 32bit ID registers as RAZ/WI on 64bit-only system
Date: Wed, 17 Aug 2022 21:48:12 +0000	[thread overview]
Message-ID: <20220817214818.3243383-1-oliver.upton@linux.dev> (raw)

For reasons unknown, the Arm architecture defines the 64-bit views of
the 32-bit ID registers as UNKNOWN [1]. This combines poorly with the
fact that KVM unconditionally exposes these registers to userspace,
which could throw a wrench in migration between 64-bit only systems.

This series reworks KVM's definition of these registers to RAZ/WI with
the goal of providing consistent register values across 64-bit machines.

Patches 1-2 clean up some of the ID register accessors, taking advantage
of the fact that the generic ones already know how to handle RAZ
registers.

Patches 3-4 wire in a new visibility bit to indicate a register ignores
writes from userspace.

Patch 5 moves all exposed 32-bit ID registers to have RAZ/WI behavior on
64-bit only systems. Note that hidden 32-bit registers continue to have
RAZ behavior and carry the additional requirement of invariance.

Lastly, patch 6 tests that userspace and guest indeed see the registers
as RAZ/WI.

Applies to 6.0-rc1 + the mismatched system fixes [2] picked up earlier
today. Tested on the fast model, both with mismatched AArch32 support
and no AArch32 support whatoever.

[1]: DDI0487H.a Table D12-2 'Instruction encodings for non-Debug System Register accesses'
[2]: https://lore.kernel.org/kvmarm/20220816192554.1455559-1-oliver.upton@linux.dev/

Oliver Upton (6):
  KVM: arm64: Use visibility hook to treat ID regs as RAZ
  KVM: arm64: Remove internal accessor helpers for id regs
  KVM: arm64: Spin off helper for calling visibility hook
  KVM: arm64: Add a visibility bit to ignore user writes
  KVM: arm64: Treat 32bit ID registers as RAZ/WI on 64bit-only system
  KVM: selftests: Add test for RAZ/WI AArch32 ID registers

 arch/arm64/kvm/sys_regs.c                     | 137 +++++++++---------
 arch/arm64/kvm/sys_regs.h                     |  24 ++-
 tools/testing/selftests/kvm/.gitignore        |   1 +
 tools/testing/selftests/kvm/Makefile          |   1 +
 .../kvm/aarch64/aarch64_only_id_regs.c        | 135 +++++++++++++++++
 5 files changed, 222 insertions(+), 76 deletions(-)
 create mode 100644 tools/testing/selftests/kvm/aarch64/aarch64_only_id_regs.c

-- 
2.37.1.595.g718a3a8f04-goog

_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

WARNING: multiple messages have this Message-ID (diff)
From: Oliver Upton <oliver.upton@linux.dev>
To: kvmarm@lists.cs.columbia.edu
Cc: kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	maz@kernel.org, james.morse@arm.com, alexandru.elisei@arm.com,
	suzuki.poulose@arm.com, will@kernel.org,
	Oliver Upton <oliver.upton@linux.dev>
Subject: [PATCH 0/6] KVM: arm64: Treat 32bit ID registers as RAZ/WI on 64bit-only system
Date: Wed, 17 Aug 2022 21:48:12 +0000	[thread overview]
Message-ID: <20220817214818.3243383-1-oliver.upton@linux.dev> (raw)

For reasons unknown, the Arm architecture defines the 64-bit views of
the 32-bit ID registers as UNKNOWN [1]. This combines poorly with the
fact that KVM unconditionally exposes these registers to userspace,
which could throw a wrench in migration between 64-bit only systems.

This series reworks KVM's definition of these registers to RAZ/WI with
the goal of providing consistent register values across 64-bit machines.

Patches 1-2 clean up some of the ID register accessors, taking advantage
of the fact that the generic ones already know how to handle RAZ
registers.

Patches 3-4 wire in a new visibility bit to indicate a register ignores
writes from userspace.

Patch 5 moves all exposed 32-bit ID registers to have RAZ/WI behavior on
64-bit only systems. Note that hidden 32-bit registers continue to have
RAZ behavior and carry the additional requirement of invariance.

Lastly, patch 6 tests that userspace and guest indeed see the registers
as RAZ/WI.

Applies to 6.0-rc1 + the mismatched system fixes [2] picked up earlier
today. Tested on the fast model, both with mismatched AArch32 support
and no AArch32 support whatoever.

[1]: DDI0487H.a Table D12-2 'Instruction encodings for non-Debug System Register accesses'
[2]: https://lore.kernel.org/kvmarm/20220816192554.1455559-1-oliver.upton@linux.dev/

Oliver Upton (6):
  KVM: arm64: Use visibility hook to treat ID regs as RAZ
  KVM: arm64: Remove internal accessor helpers for id regs
  KVM: arm64: Spin off helper for calling visibility hook
  KVM: arm64: Add a visibility bit to ignore user writes
  KVM: arm64: Treat 32bit ID registers as RAZ/WI on 64bit-only system
  KVM: selftests: Add test for RAZ/WI AArch32 ID registers

 arch/arm64/kvm/sys_regs.c                     | 137 +++++++++---------
 arch/arm64/kvm/sys_regs.h                     |  24 ++-
 tools/testing/selftests/kvm/.gitignore        |   1 +
 tools/testing/selftests/kvm/Makefile          |   1 +
 .../kvm/aarch64/aarch64_only_id_regs.c        | 135 +++++++++++++++++
 5 files changed, 222 insertions(+), 76 deletions(-)
 create mode 100644 tools/testing/selftests/kvm/aarch64/aarch64_only_id_regs.c

-- 
2.37.1.595.g718a3a8f04-goog


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

WARNING: multiple messages have this Message-ID (diff)
From: Oliver Upton <oliver.upton@linux.dev>
To: kvmarm@lists.cs.columbia.edu
Cc: kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	maz@kernel.org, james.morse@arm.com, alexandru.elisei@arm.com,
	suzuki.poulose@arm.com, will@kernel.org,
	Oliver Upton <oliver.upton@linux.dev>
Subject: [PATCH 0/6] KVM: arm64: Treat 32bit ID registers as RAZ/WI on 64bit-only system
Date: Wed, 17 Aug 2022 21:48:12 +0000	[thread overview]
Message-ID: <20220817214818.3243383-1-oliver.upton@linux.dev> (raw)

For reasons unknown, the Arm architecture defines the 64-bit views of
the 32-bit ID registers as UNKNOWN [1]. This combines poorly with the
fact that KVM unconditionally exposes these registers to userspace,
which could throw a wrench in migration between 64-bit only systems.

This series reworks KVM's definition of these registers to RAZ/WI with
the goal of providing consistent register values across 64-bit machines.

Patches 1-2 clean up some of the ID register accessors, taking advantage
of the fact that the generic ones already know how to handle RAZ
registers.

Patches 3-4 wire in a new visibility bit to indicate a register ignores
writes from userspace.

Patch 5 moves all exposed 32-bit ID registers to have RAZ/WI behavior on
64-bit only systems. Note that hidden 32-bit registers continue to have
RAZ behavior and carry the additional requirement of invariance.

Lastly, patch 6 tests that userspace and guest indeed see the registers
as RAZ/WI.

Applies to 6.0-rc1 + the mismatched system fixes [2] picked up earlier
today. Tested on the fast model, both with mismatched AArch32 support
and no AArch32 support whatoever.

[1]: DDI0487H.a Table D12-2 'Instruction encodings for non-Debug System Register accesses'
[2]: https://lore.kernel.org/kvmarm/20220816192554.1455559-1-oliver.upton@linux.dev/

Oliver Upton (6):
  KVM: arm64: Use visibility hook to treat ID regs as RAZ
  KVM: arm64: Remove internal accessor helpers for id regs
  KVM: arm64: Spin off helper for calling visibility hook
  KVM: arm64: Add a visibility bit to ignore user writes
  KVM: arm64: Treat 32bit ID registers as RAZ/WI on 64bit-only system
  KVM: selftests: Add test for RAZ/WI AArch32 ID registers

 arch/arm64/kvm/sys_regs.c                     | 137 +++++++++---------
 arch/arm64/kvm/sys_regs.h                     |  24 ++-
 tools/testing/selftests/kvm/.gitignore        |   1 +
 tools/testing/selftests/kvm/Makefile          |   1 +
 .../kvm/aarch64/aarch64_only_id_regs.c        | 135 +++++++++++++++++
 5 files changed, 222 insertions(+), 76 deletions(-)
 create mode 100644 tools/testing/selftests/kvm/aarch64/aarch64_only_id_regs.c

-- 
2.37.1.595.g718a3a8f04-goog


             reply	other threads:[~2022-08-17 21:48 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-17 21:48 Oliver Upton [this message]
2022-08-17 21:48 ` [PATCH 0/6] KVM: arm64: Treat 32bit ID registers as RAZ/WI on 64bit-only system Oliver Upton
2022-08-17 21:48 ` Oliver Upton
2022-08-17 21:48 ` [PATCH 1/6] KVM: arm64: Use visibility hook to treat ID regs as RAZ Oliver Upton
2022-08-17 21:48   ` Oliver Upton
2022-08-17 21:48   ` Oliver Upton
2022-08-30  4:54   ` Reiji Watanabe
2022-08-30  4:54     ` Reiji Watanabe
2022-08-30  4:54     ` Reiji Watanabe
2022-08-17 21:48 ` [PATCH 2/6] KVM: arm64: Remove internal accessor helpers for id regs Oliver Upton
2022-08-17 21:48   ` Oliver Upton
2022-08-17 21:48   ` Oliver Upton
2022-08-30  5:45   ` Reiji Watanabe
2022-08-30  5:45     ` Reiji Watanabe
2022-08-30  5:45     ` Reiji Watanabe
2022-08-30 17:45     ` Oliver Upton
2022-08-30 17:45       ` Oliver Upton
2022-08-30 17:45       ` Oliver Upton
2022-08-17 21:48 ` [PATCH 3/6] KVM: arm64: Spin off helper for calling visibility hook Oliver Upton
2022-08-17 21:48   ` Oliver Upton
2022-08-17 21:48   ` Oliver Upton
2022-08-30  6:01   ` Reiji Watanabe
2022-08-30  6:01     ` Reiji Watanabe
2022-08-30  6:01     ` Reiji Watanabe
2022-08-17 21:48 ` [PATCH 4/6] KVM: arm64: Add a visibility bit to ignore user writes Oliver Upton
2022-08-17 21:48   ` Oliver Upton
2022-08-17 21:48   ` Oliver Upton
2022-08-31  3:29   ` Reiji Watanabe
2022-08-31  3:29     ` Reiji Watanabe
2022-08-31  3:29     ` Reiji Watanabe
2022-08-31 14:42     ` Oliver Upton
2022-08-31 14:42       ` Oliver Upton
2022-08-31 14:42       ` Oliver Upton
2022-09-01  4:57       ` Reiji Watanabe
2022-09-01  4:57         ` Reiji Watanabe
2022-09-01  4:57         ` Reiji Watanabe
2022-08-17 21:48 ` [PATCH 5/6] KVM: arm64: Treat 32bit ID registers as RAZ/WI on 64bit-only system Oliver Upton
2022-08-17 21:48   ` Oliver Upton
2022-08-17 21:48   ` Oliver Upton
2022-08-23 17:05   ` Marc Zyngier
2022-08-23 17:05     ` Marc Zyngier
2022-08-23 17:05     ` Marc Zyngier
2022-08-23 17:27     ` Oliver Upton
2022-08-23 17:27       ` Oliver Upton
2022-08-23 17:27       ` Oliver Upton
2022-08-17 21:48 ` [PATCH 6/6] KVM: selftests: Add test for RAZ/WI AArch32 ID registers Oliver Upton
2022-08-17 21:48   ` Oliver Upton
2022-08-17 21:48   ` Oliver Upton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220817214818.3243383-1-oliver.upton@linux.dev \
    --to=oliver.upton@linux.dev \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=maz@kernel.org \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.