Skip to contentSkip to conversation

RISC-V: KVM: Require alternatives

PATCH New Andrew Jones 4 participants 11 messages Mar 22, 2023 – Apr 7, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover RISC-V: KVM: Require alternatives

KVM makes use of riscv_has_extension_unlikely() to check for the svinval extension. riscv_has_extension_unlikely() is built on alternatives, which means KVM should ensure alternatives support is available.

The first patch takes the opportunity to cleanup KVM's select list. The second patch selects RISCV_ALTERNATIVE.

Thanks,
drew

Andrew Jones (2):
RISC-V: KVM: Alphabetize selects
RISC-V: KVM: Require alternatives

 arch/riscv/kvm/Kconfig | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
Signature · 1 line
2.39.2
#1 lore raw

PATCH 1/2 RISC-V: KVM: Alphabetize selects

While alphabetized lists tend to become unalphabetized almost as quickly as they get fixed up, it is preferred to keep select lists in Kconfigs in order. Let's fix KVM's up.

---
 arch/riscv/kvm/Kconfig | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
arch/riscv/kvm/Kconfig +5 -5
index d5a658a047a7..5bcb2d519b95 100644
@@ -20,14 +20,14 @@ if VIRTUALIZATION
 config KVM
 	tristate "Kernel-based Virtual Machine (KVM) support (EXPERIMENTAL)"
 	depends on RISCV_SBI && MMU
+	select HAVE_KVM_EVENTFD
+	select HAVE_KVM_VCPU_ASYNC_IOCTL
+	select KVM_GENERIC_DIRTYLOG_READ_PROTECT
 	select KVM_GENERIC_HARDWARE_ENABLING
-	select MMU_NOTIFIER
-	select PREEMPT_NOTIFIERS
 	select KVM_MMIO
-	select KVM_GENERIC_DIRTYLOG_READ_PROTECT
 	select KVM_XFER_TO_GUEST_WORK
-	select HAVE_KVM_VCPU_ASYNC_IOCTL
-	select HAVE_KVM_EVENTFD
+	select MMU_NOTIFIER
+	select PREEMPT_NOTIFIERS
 	select SRCU
 	help
 	  Support hosting virtualized guest machines.
Signature · 1 line
2.39.2
maintainer
#2 lore raw

PATCH 1/2 RISC-V: KVM: Alphabetize selects

Quoted 6 lines · On Thu, Mar 23, 2023 at 12:59?AM Andrew Jones <[email protected]> wrote:

While alphabetized lists tend to become unalphabetized almost as quickly as they get fixed up, it is preferred to keep select lists in Kconfigs in order. Let's fix KVM's up.

Queued this patch for Linux-6.4

Thanks,
Anup

Quoted 31 lines
---
 arch/riscv/kvm/Kconfig | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
arch/riscv/kvm/Kconfig +5 -6
index d5a658a047a7..5bcb2d519b95 100644
@@ -20,14 +20,14 @@ if VIRTUALIZATION
 config KVM
        tristate "Kernel-based Virtual Machine (KVM) support (EXPERIMENTAL)"
        depends on RISCV_SBI && MMU
+       select HAVE_KVM_EVENTFD
+       select HAVE_KVM_VCPU_ASYNC_IOCTL
+       select KVM_GENERIC_DIRTYLOG_READ_PROTECT
        select KVM_GENERIC_HARDWARE_ENABLING
-       select MMU_NOTIFIER
-       select PREEMPT_NOTIFIERS
        select KVM_MMIO
-       select KVM_GENERIC_DIRTYLOG_READ_PROTECT
        select KVM_XFER_TO_GUEST_WORK
-       select HAVE_KVM_VCPU_ASYNC_IOCTL
-       select HAVE_KVM_EVENTFD
+       select MMU_NOTIFIER
+       select PREEMPT_NOTIFIERS
        select SRCU
        help
          Support hosting virtualized guest machines.
--

2.39.2

#3 lore raw

PATCH 2/2 RISC-V: KVM: Require alternatives

In reply to Andrew Jones

KVM makes use of riscv_has_extension_unlikely() to check for the svinval extension. riscv_has_extension_unlikely() is built on alternatives, which means KVM should ensure alternatives support is available. Select RISCV_ALTERNATIVE from KVM.

Fixes e8ad17d2b5f3 ("riscv: KVM: Switch has_svinval() to riscv_has_extension_unlikely()")
---
 arch/riscv/kvm/Kconfig | 1 +
 1 file changed, 1 insertion(+)
arch/riscv/kvm/Kconfig +1 -0
index 5bcb2d519b95..9dd61db0acc5 100644
@@ -28,6 +28,7 @@ config KVM
 	select KVM_XFER_TO_GUEST_WORK
 	select MMU_NOTIFIER
 	select PREEMPT_NOTIFIERS
+	select RISCV_ALTERNATIVE
 	select SRCU
 	help
 	  Support hosting virtualized guest machines.
Signature · 1 line
2.39.2
#4 lore raw

cover RISC-V: KVM: Require alternatives

In reply to Andrew Jones
Quoted 7 lines · Andrew Jones

KVM makes use of riscv_has_extension_unlikely() to check for the svinval extension. riscv_has_extension_unlikely() is built on alternatives, which means KVM should ensure alternatives support is available.

The first patch takes the opportunity to cleanup KVM's select list. The second patch selects RISCV_ALTERNATIVE.

Reminds me, I need to re-submit my patch doing that for the top-level RISC-V Kconfig...
For the pair:

Thanks,
Conor.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/kvm-riscv/attachments/20230322/5f47598b/attachment-0001.sig>

#5 lore raw

cover RISC-V: KVM: Require alternatives

Quoted 6 lines · Conor Dooley
Quoted 5 lines · Andrew Jones

KVM makes use of riscv_has_extension_unlikely() to check for the svinval extension. riscv_has_extension_unlikely() is built on alternatives, which means KVM should ensure alternatives support is available.

Quoted 7 lines
Quoted 2 lines

The first patch takes the opportunity to cleanup KVM's select list. The second patch selects RISCV_ALTERNATIVE.

Reminds me, I need to re-submit my patch doing that for the top-level RISC-V Kconfig...
For the pair:

Actually, I would like to take this back for patch 2.
Per the discussion on the other thread about XIP [1], I don't think that KVM should be selecting alternatives like this.
Would you mind if I picked up these patches & submitted them as a v2, alongside a patch trying to make sure that we do not clip the wings of of XIP kernels by selecting RISCV_ALTERNATIVE?

Cheers,
Conor.

1 - https://lore.kernel.org/all/20230322120907.2968494-1-Jason at zx2c4.com/ -------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/kvm-riscv/attachments/20230323/c4a44a6e/attachment-0001.sig>

#6 lore raw

cover RISC-V: KVM: Require alternatives

Quoted 15 lines · Conor Dooley
Quoted 6 lines · Conor Dooley
Quoted 5 lines · Andrew Jones

KVM makes use of riscv_has_extension_unlikely() to check for the svinval extension. riscv_has_extension_unlikely() is built on alternatives, which means KVM should ensure alternatives support is available.

Quoted 7 lines
Quoted 2 lines

The first patch takes the opportunity to cleanup KVM's select list. The second patch selects RISCV_ALTERNATIVE.

Reminds me, I need to re-submit my patch doing that for the top-level RISC-V Kconfig...
For the pair:

Quoted 7 lines

Actually, I would like to take this back for patch 2.
Per the discussion on the other thread about XIP [1], I don't think that KVM should be selecting alternatives like this.
Would you mind if I picked up these patches & submitted them as a v2, alongside a patch trying to make sure that we do not clip the wings of of XIP kernels by selecting RISCV_ALTERNATIVE?

Sounds good to me. Thanks, Conor.

drew

#7 lore raw

cover RISC-V: KVM: Require alternatives

In reply to Conor Dooley
Quoted 15 lines · Conor Dooley
Quoted 6 lines · Conor Dooley
Quoted 5 lines · Andrew Jones

KVM makes use of riscv_has_extension_unlikely() to check for the svinval extension. riscv_has_extension_unlikely() is built on alternatives, which means KVM should ensure alternatives support is available.

Quoted 7 lines
Quoted 2 lines

The first patch takes the opportunity to cleanup KVM's select list. The second patch selects RISCV_ALTERNATIVE.

Reminds me, I need to re-submit my patch doing that for the top-level RISC-V Kconfig...
For the pair:

Quoted 6 lines

Actually, I would like to take this back for patch 2.
Per the discussion on the other thread about XIP [1], I don't think that KVM should be selecting alternatives like this.
Would you mind if I picked up these patches & submitted them as a v2, alongside a patch trying to make sure that we do not clip the wings of of XIP kernels by selecting RISCV_ALTERNATIVE?

Hi Conor,

I take it that resubmitting these patches is no longer part of the plan. Should I rebase on "[PATCH v1 0/2] RISC-V: Fixes for riscv_has_extension[un]likely()'s alternative dependency" and change the select to a depends on?

Thanks,
drew

#8 lore raw

cover RISC-V: KVM: Require alternatives

Quoted 23 lines · Andrew Jones
Quoted 15 lines · Conor Dooley
Quoted 6 lines · Conor Dooley
Quoted 5 lines · Andrew Jones

KVM makes use of riscv_has_extension_unlikely() to check for the svinval extension. riscv_has_extension_unlikely() is built on alternatives, which means KVM should ensure alternatives support is available.

Quoted 7 lines
Quoted 2 lines

The first patch takes the opportunity to cleanup KVM's select list. The second patch selects RISCV_ALTERNATIVE.

Reminds me, I need to re-submit my patch doing that for the top-level RISC-V Kconfig...
For the pair:

Quoted 6 lines

Actually, I would like to take this back for patch 2.
Per the discussion on the other thread about XIP [1], I don't think that KVM should be selecting alternatives like this.
Would you mind if I picked up these patches & submitted them as a v2, alongside a patch trying to make sure that we do not clip the wings of of XIP kernels by selecting RISCV_ALTERNATIVE?

Quoted 3 lines

Hi Conor,

I take it that resubmitting these patches is no longer part of the plan.

Ah crap, sorry. I meant to reply here after submitting and forgot.

Quoted 3 lines

Should I rebase on "[PATCH v1 0/2] RISC-V: Fixes for riscv_has_extension[un]likely()'s alternative dependency" and change the select to a depends on?

I don't think you need to. Does KVM actually make use of alternatives, other than for riscv_has_extension_unlikely(), that are not gated by extension/erratum specific config options?

With my patch 2/2, alternatives are always enabled for !XIP_KERNEL
builds, and will fall back to the "slow" path in
riscv_has_extension_unlikely() otherwise.
If KVM doesn't need alternatives for another reason, I don't think you
need to introduce a dependency on them and just inherit the decision
made by CONFIG_RISCV.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/kvm-riscv/attachments/20230324/d18529fd/attachment-0001.sig>

#9 lore raw

cover RISC-V: KVM: Require alternatives

Quoted 38 lines · Conor Dooley
Quoted 23 lines · Andrew Jones
Quoted 15 lines · Conor Dooley
Quoted 6 lines · Conor Dooley
Quoted 5 lines · Andrew Jones

KVM makes use of riscv_has_extension_unlikely() to check for the svinval extension. riscv_has_extension_unlikely() is built on alternatives, which means KVM should ensure alternatives support is available.

Quoted 7 lines
Quoted 2 lines

The first patch takes the opportunity to cleanup KVM's select list. The second patch selects RISCV_ALTERNATIVE.

Reminds me, I need to re-submit my patch doing that for the top-level RISC-V Kconfig...
For the pair:

Quoted 6 lines

Actually, I would like to take this back for patch 2.
Per the discussion on the other thread about XIP [1], I don't think that KVM should be selecting alternatives like this.
Would you mind if I picked up these patches & submitted them as a v2, alongside a patch trying to make sure that we do not clip the wings of of XIP kernels by selecting RISCV_ALTERNATIVE?

Quoted 3 lines

Hi Conor,

I take it that resubmitting these patches is no longer part of the plan.

Ah crap, sorry. I meant to reply here after submitting and forgot.

Quoted 3 lines

Should I rebase on "[PATCH v1 0/2] RISC-V: Fixes for riscv_has_extension[un]likely()'s alternative dependency" and change the select to a depends on?

I don't think you need to. Does KVM actually make use of alternatives, other than for riscv_has_extension_unlikely(), that are not gated by extension/erratum specific config options?

Quoted 6 lines

With my patch 2/2, alternatives are always enabled for !XIP_KERNEL builds, and will fall back to the "slow" path in riscv_has_extension_unlikely() otherwise.
If KVM doesn't need alternatives for another reason, I don't think you need to introduce a dependency on them and just inherit the decision made by CONFIG_RISCV.

Ack, thanks, Conor.

Anup, we can either drop patch 2/2 or the whole series, as you like.

Thanks,
drew

maintainer
#10 lore raw

cover RISC-V: KVM: Require alternatives

Quoted 47 lines · On Fri, Mar 24, 2023 at 5:26?PM Andrew Jones <[email protected]> wrote:
Quoted 38 lines · Conor Dooley
Quoted 23 lines · Andrew Jones
Quoted 15 lines · Conor Dooley
Quoted 6 lines · Conor Dooley
Quoted 5 lines · Andrew Jones

KVM makes use of riscv_has_extension_unlikely() to check for the svinval extension. riscv_has_extension_unlikely() is built on alternatives, which means KVM should ensure alternatives support is available.

Quoted 7 lines
Quoted 2 lines

The first patch takes the opportunity to cleanup KVM's select list. The second patch selects RISCV_ALTERNATIVE.

Reminds me, I need to re-submit my patch doing that for the top-level RISC-V Kconfig...
For the pair:

Quoted 6 lines

Actually, I would like to take this back for patch 2.
Per the discussion on the other thread about XIP [1], I don't think that KVM should be selecting alternatives like this.
Would you mind if I picked up these patches & submitted them as a v2, alongside a patch trying to make sure that we do not clip the wings of of XIP kernels by selecting RISCV_ALTERNATIVE?

Quoted 3 lines

Hi Conor,

I take it that resubmitting these patches is no longer part of the plan.

Ah crap, sorry. I meant to reply here after submitting and forgot.

Quoted 3 lines

Should I rebase on "[PATCH v1 0/2] RISC-V: Fixes for riscv_has_extension[un]likely()'s alternative dependency" and change the select to a depends on?

I don't think you need to. Does KVM actually make use of alternatives, other than for riscv_has_extension_unlikely(), that are not gated by extension/erratum specific config options?

Quoted 6 lines

With my patch 2/2, alternatives are always enabled for !XIP_KERNEL builds, and will fall back to the "slow" path in riscv_has_extension_unlikely() otherwise.
If KVM doesn't need alternatives for another reason, I don't think you need to introduce a dependency on them and just inherit the decision made by CONFIG_RISCV.

Quoted 3 lines

Ack, thanks, Conor.

Anup, we can either drop patch 2/2 or the whole series, as you like.

If alternatives are going to be always enabled for !XIP_KERNEL then we can drop PATCH2. I am okay taking PATCH1.

Regards,
Anup