* [RFC PATCH kernel] KVM: PPC: Book3S PR: Fix WIMG handling under pHyp
@ 2017-11-22 3:42 ` Alexey Kardashevskiy
0 siblings, 0 replies; 13+ messages in thread
From: Alexey Kardashevskiy @ 2017-11-22 3:42 UTC (permalink / raw)
To: linuxppc-dev
Cc: Alexey Kardashevskiy, David Gibson, kvm-ppc, kvm, Alexander Graf,
Paul Mackerras
96df226 "KVM: PPC: Book3S PR: Preserve storage control bits" added WIMG
bits preserving but it missed 2 special cases:
- a magic page in kvmppc_mmu_book3s_64_xlate() and
- guest real mode in kvmppc_handle_pagefault().
For these ptes WIMG were 0 and pHyp failed on these causing a guest to
stop in the very beginning at NIP=0x100 (due to bd9166ffe
"KVM: PPC: Book3S PR: Exit KVM on failed mapping").
This initializes WIMG to non-zero value HPTE_R_M. The value is chosen
as (0x192 & HPTE_R_WIMG); 0x192 is a magic value from
kvmppc_mmu_map_page().
Fixes: 96df226 "KVM: PPC: Book3S PR: Preserve storage control bits"
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
This indeed fixes PR KVM + VFIO under pHyp but selection of HPTE_R_M
is arguable.
---
arch/powerpc/kvm/book3s_64_mmu.c | 1 +
arch/powerpc/kvm/book3s_pr.c | 1 +
2 files changed, 2 insertions(+)
diff --git a/arch/powerpc/kvm/book3s_64_mmu.c b/arch/powerpc/kvm/book3s_64_mmu.c
index 29ebe2f..a93d719 100644
--- a/arch/powerpc/kvm/book3s_64_mmu.c
+++ b/arch/powerpc/kvm/book3s_64_mmu.c
@@ -235,6 +235,7 @@ static int kvmppc_mmu_book3s_64_xlate(struct kvm_vcpu *vcpu, gva_t eaddr,
gpte->may_read = true;
gpte->may_write = true;
gpte->page_size = MMU_PAGE_4K;
+ gpte->wimg = HPTE_R_M;
return 0;
}
diff --git a/arch/powerpc/kvm/book3s_pr.c b/arch/powerpc/kvm/book3s_pr.c
index 69a0944..0152efe 100644
--- a/arch/powerpc/kvm/book3s_pr.c
+++ b/arch/powerpc/kvm/book3s_pr.c
@@ -557,6 +557,7 @@ int kvmppc_handle_pagefault(struct kvm_run *run, struct kvm_vcpu *vcpu,
pte.eaddr = eaddr;
pte.vpage = eaddr >> 12;
pte.page_size = MMU_PAGE_64K;
+ pte.wimg = HPTE_R_M;
}
switch (kvmppc_get_msr(vcpu) & (MSR_DR|MSR_IR)) {
--
2.11.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [RFC PATCH kernel] KVM: PPC: Book3S PR: Fix WIMG handling under pHyp
@ 2017-11-22 3:42 ` Alexey Kardashevskiy
0 siblings, 0 replies; 13+ messages in thread
From: Alexey Kardashevskiy @ 2017-11-22 3:42 UTC (permalink / raw)
To: linuxppc-dev
Cc: Alexey Kardashevskiy, David Gibson, kvm-ppc, kvm, Alexander Graf,
Paul Mackerras
96df226 "KVM: PPC: Book3S PR: Preserve storage control bits" added WIMG
bits preserving but it missed 2 special cases:
- a magic page in kvmppc_mmu_book3s_64_xlate() and
- guest real mode in kvmppc_handle_pagefault().
For these ptes WIMG were 0 and pHyp failed on these causing a guest to
stop in the very beginning at NIP=0x100 (due to bd9166ffe
"KVM: PPC: Book3S PR: Exit KVM on failed mapping").
This initializes WIMG to non-zero value HPTE_R_M. The value is chosen
as (0x192 & HPTE_R_WIMG); 0x192 is a magic value from
kvmppc_mmu_map_page().
Fixes: 96df226 "KVM: PPC: Book3S PR: Preserve storage control bits"
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---
This indeed fixes PR KVM + VFIO under pHyp but selection of HPTE_R_M
is arguable.
---
arch/powerpc/kvm/book3s_64_mmu.c | 1 +
arch/powerpc/kvm/book3s_pr.c | 1 +
2 files changed, 2 insertions(+)
diff --git a/arch/powerpc/kvm/book3s_64_mmu.c b/arch/powerpc/kvm/book3s_64_mmu.c
index 29ebe2f..a93d719 100644
--- a/arch/powerpc/kvm/book3s_64_mmu.c
+++ b/arch/powerpc/kvm/book3s_64_mmu.c
@@ -235,6 +235,7 @@ static int kvmppc_mmu_book3s_64_xlate(struct kvm_vcpu *vcpu, gva_t eaddr,
gpte->may_read = true;
gpte->may_write = true;
gpte->page_size = MMU_PAGE_4K;
+ gpte->wimg = HPTE_R_M;
return 0;
}
diff --git a/arch/powerpc/kvm/book3s_pr.c b/arch/powerpc/kvm/book3s_pr.c
index 69a0944..0152efe 100644
--- a/arch/powerpc/kvm/book3s_pr.c
+++ b/arch/powerpc/kvm/book3s_pr.c
@@ -557,6 +557,7 @@ int kvmppc_handle_pagefault(struct kvm_run *run, struct kvm_vcpu *vcpu,
pte.eaddr = eaddr;
pte.vpage = eaddr >> 12;
pte.page_size = MMU_PAGE_64K;
+ pte.wimg = HPTE_R_M;
}
switch (kvmppc_get_msr(vcpu) & (MSR_DR|MSR_IR)) {
--
2.11.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [RFC PATCH kernel] KVM: PPC: Book3S PR: Fix WIMG handling under pHyp
2017-11-22 3:42 ` Alexey Kardashevskiy
@ 2017-11-22 15:02 ` Alexander Graf
-1 siblings, 0 replies; 13+ messages in thread
From: Alexander Graf @ 2017-11-22 15:02 UTC (permalink / raw)
To: Alexey Kardashevskiy, linuxppc-dev
Cc: David Gibson, Paul Mackerras, kvm, kvm-ppc, Ruediger Oertel
On 22.11.17 04:42, Alexey Kardashevskiy wrote:
> 96df226 "KVM: PPC: Book3S PR: Preserve storage control bits" added WIMG
> bits preserving but it missed 2 special cases:
> - a magic page in kvmppc_mmu_book3s_64_xlate() and
> - guest real mode in kvmppc_handle_pagefault().
>
> For these ptes WIMG were 0 and pHyp failed on these causing a guest to
> stop in the very beginning at NIP=0x100 (due to bd9166ffe
> "KVM: PPC: Book3S PR: Exit KVM on failed mapping").
>
> This initializes WIMG to non-zero value HPTE_R_M. The value is chosen
> as (0x192 & HPTE_R_WIMG); 0x192 is a magic value from
> kvmppc_mmu_map_page().
>
> Fixes: 96df226 "KVM: PPC: Book3S PR: Preserve storage control bits"
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> ---
>
> This indeed fixes PR KVM + VFIO under pHyp but selection of HPTE_R_M
> is arguable.
This does indeed fix the breakage we've seen:
Tested-by: Ruediger Oertel <ro@suse.de>
Alex
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [RFC PATCH kernel] KVM: PPC: Book3S PR: Fix WIMG handling under pHyp
@ 2017-11-22 15:02 ` Alexander Graf
0 siblings, 0 replies; 13+ messages in thread
From: Alexander Graf @ 2017-11-22 15:02 UTC (permalink / raw)
To: Alexey Kardashevskiy, linuxppc-dev
Cc: David Gibson, Paul Mackerras, kvm, kvm-ppc, Ruediger Oertel
On 22.11.17 04:42, Alexey Kardashevskiy wrote:
> 96df226 "KVM: PPC: Book3S PR: Preserve storage control bits" added WIMG
> bits preserving but it missed 2 special cases:
> - a magic page in kvmppc_mmu_book3s_64_xlate() and
> - guest real mode in kvmppc_handle_pagefault().
>
> For these ptes WIMG were 0 and pHyp failed on these causing a guest to
> stop in the very beginning at NIP=0x100 (due to bd9166ffe
> "KVM: PPC: Book3S PR: Exit KVM on failed mapping").
>
> This initializes WIMG to non-zero value HPTE_R_M. The value is chosen
> as (0x192 & HPTE_R_WIMG); 0x192 is a magic value from
> kvmppc_mmu_map_page().
>
> Fixes: 96df226 "KVM: PPC: Book3S PR: Preserve storage control bits"
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> ---
>
> This indeed fixes PR KVM + VFIO under pHyp but selection of HPTE_R_M
> is arguable.
This does indeed fix the breakage we've seen:
Tested-by: Ruediger Oertel <ro@suse.de>
Alex
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [RFC PATCH kernel] KVM: PPC: Book3S PR: Fix WIMG handling under pHyp
2017-11-22 3:42 ` Alexey Kardashevskiy
(?)
@ 2017-11-23 23:33 ` Greg Kurz
-1 siblings, 0 replies; 13+ messages in thread
From: Greg Kurz @ 2017-11-23 23:33 UTC (permalink / raw)
To: Alexey Kardashevskiy
Cc: kvm, kvm-ppc, Paul Mackerras, linuxppc-dev, Alexander Graf, David Gibson
On Wed, 22 Nov 2017 14:42:21 +1100
Alexey Kardashevskiy <aik@ozlabs.ru> wrote:
> 96df226 "KVM: PPC: Book3S PR: Preserve storage control bits" added WIMG
> bits preserving but it missed 2 special cases:
> - a magic page in kvmppc_mmu_book3s_64_xlate() and
> - guest real mode in kvmppc_handle_pagefault().
>
> For these ptes WIMG were 0 and pHyp failed on these causing a guest to
> stop in the very beginning at NIP=0x100 (due to bd9166ffe
> "KVM: PPC: Book3S PR: Exit KVM on failed mapping").
>
> This initializes WIMG to non-zero value HPTE_R_M. The value is chosen
> as (0x192 & HPTE_R_WIMG); 0x192 is a magic value from
> kvmppc_mmu_map_page().
>
> Fixes: 96df226 "KVM: PPC: Book3S PR: Preserve storage control bits"
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> ---
>
> This indeed fixes PR KVM + VFIO under pHyp but selection of HPTE_R_M
> is arguable.
>
The initial page fault at 0x100 on machine startup causes H_ENTER to fail in
pHyp with H_PARAMETER, as described in PAPR:
The hypervisor checks that the WIMG bits within the PTE are appropriate for the
physical page number else H_Parameter return. (For System Memory pages WIMG=0010,
or, 1110 if the SAO option is enabled, and for IO pages WIMG=01**.)
I'm not aware we care for SAO so HPTE_R_M looks like the only sensible choice,
or I'm missing something ?
Anyway, this patch allows to start a PR guest on PowerVM again.
Reviewed-by: Greg Kurz <groug@kaod.org>
and
Tested-by: Greg Kurz <groug@kaod.org>
> ---
> arch/powerpc/kvm/book3s_64_mmu.c | 1 +
> arch/powerpc/kvm/book3s_pr.c | 1 +
> 2 files changed, 2 insertions(+)
>
> diff --git a/arch/powerpc/kvm/book3s_64_mmu.c b/arch/powerpc/kvm/book3s_64_mmu.c
> index 29ebe2f..a93d719 100644
> --- a/arch/powerpc/kvm/book3s_64_mmu.c
> +++ b/arch/powerpc/kvm/book3s_64_mmu.c
> @@ -235,6 +235,7 @@ static int kvmppc_mmu_book3s_64_xlate(struct kvm_vcpu *vcpu, gva_t eaddr,
> gpte->may_read = true;
> gpte->may_write = true;
> gpte->page_size = MMU_PAGE_4K;
> + gpte->wimg = HPTE_R_M;
>
> return 0;
> }
> diff --git a/arch/powerpc/kvm/book3s_pr.c b/arch/powerpc/kvm/book3s_pr.c
> index 69a0944..0152efe 100644
> --- a/arch/powerpc/kvm/book3s_pr.c
> +++ b/arch/powerpc/kvm/book3s_pr.c
> @@ -557,6 +557,7 @@ int kvmppc_handle_pagefault(struct kvm_run *run, struct kvm_vcpu *vcpu,
> pte.eaddr = eaddr;
> pte.vpage = eaddr >> 12;
> pte.page_size = MMU_PAGE_64K;
> + pte.wimg = HPTE_R_M;
> }
>
> switch (kvmppc_get_msr(vcpu) & (MSR_DR|MSR_IR)) {
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [RFC PATCH kernel] KVM: PPC: Book3S PR: Fix WIMG handling under pHyp
@ 2017-11-23 23:33 ` Greg Kurz
0 siblings, 0 replies; 13+ messages in thread
From: Greg Kurz @ 2017-11-23 23:33 UTC (permalink / raw)
To: Alexey Kardashevskiy
Cc: linuxppc-dev, David Gibson, kvm-ppc, kvm, Alexander Graf, Paul Mackerras
On Wed, 22 Nov 2017 14:42:21 +1100
Alexey Kardashevskiy <aik@ozlabs.ru> wrote:
> 96df226 "KVM: PPC: Book3S PR: Preserve storage control bits" added WIMG
> bits preserving but it missed 2 special cases:
> - a magic page in kvmppc_mmu_book3s_64_xlate() and
> - guest real mode in kvmppc_handle_pagefault().
>
> For these ptes WIMG were 0 and pHyp failed on these causing a guest to
> stop in the very beginning at NIP=0x100 (due to bd9166ffe
> "KVM: PPC: Book3S PR: Exit KVM on failed mapping").
>
> This initializes WIMG to non-zero value HPTE_R_M. The value is chosen
> as (0x192 & HPTE_R_WIMG); 0x192 is a magic value from
> kvmppc_mmu_map_page().
>
> Fixes: 96df226 "KVM: PPC: Book3S PR: Preserve storage control bits"
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> ---
>
> This indeed fixes PR KVM + VFIO under pHyp but selection of HPTE_R_M
> is arguable.
>
The initial page fault at 0x100 on machine startup causes H_ENTER to fail in
pHyp with H_PARAMETER, as described in PAPR:
The hypervisor checks that the WIMG bits within the PTE are appropriate for the
physical page number else H_Parameter return. (For System Memory pages WIMG=0010,
or, 1110 if the SAO option is enabled, and for IO pages WIMG=01**.)
I'm not aware we care for SAO so HPTE_R_M looks like the only sensible choice,
or I'm missing something ?
Anyway, this patch allows to start a PR guest on PowerVM again.
Reviewed-by: Greg Kurz <groug@kaod.org>
and
Tested-by: Greg Kurz <groug@kaod.org>
> ---
> arch/powerpc/kvm/book3s_64_mmu.c | 1 +
> arch/powerpc/kvm/book3s_pr.c | 1 +
> 2 files changed, 2 insertions(+)
>
> diff --git a/arch/powerpc/kvm/book3s_64_mmu.c b/arch/powerpc/kvm/book3s_64_mmu.c
> index 29ebe2f..a93d719 100644
> --- a/arch/powerpc/kvm/book3s_64_mmu.c
> +++ b/arch/powerpc/kvm/book3s_64_mmu.c
> @@ -235,6 +235,7 @@ static int kvmppc_mmu_book3s_64_xlate(struct kvm_vcpu *vcpu, gva_t eaddr,
> gpte->may_read = true;
> gpte->may_write = true;
> gpte->page_size = MMU_PAGE_4K;
> + gpte->wimg = HPTE_R_M;
>
> return 0;
> }
> diff --git a/arch/powerpc/kvm/book3s_pr.c b/arch/powerpc/kvm/book3s_pr.c
> index 69a0944..0152efe 100644
> --- a/arch/powerpc/kvm/book3s_pr.c
> +++ b/arch/powerpc/kvm/book3s_pr.c
> @@ -557,6 +557,7 @@ int kvmppc_handle_pagefault(struct kvm_run *run, struct kvm_vcpu *vcpu,
> pte.eaddr = eaddr;
> pte.vpage = eaddr >> 12;
> pte.page_size = MMU_PAGE_64K;
> + pte.wimg = HPTE_R_M;
> }
>
> switch (kvmppc_get_msr(vcpu) & (MSR_DR|MSR_IR)) {
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [RFC PATCH kernel] KVM: PPC: Book3S PR: Fix WIMG handling under pHyp
@ 2017-11-23 23:33 ` Greg Kurz
0 siblings, 0 replies; 13+ messages in thread
From: Greg Kurz @ 2017-11-23 23:33 UTC (permalink / raw)
To: Alexey Kardashevskiy
Cc: kvm, kvm-ppc, Paul Mackerras, linuxppc-dev, Alexander Graf, David Gibson
On Wed, 22 Nov 2017 14:42:21 +1100
Alexey Kardashevskiy <aik@ozlabs.ru> wrote:
> 96df226 "KVM: PPC: Book3S PR: Preserve storage control bits" added WIMG
> bits preserving but it missed 2 special cases:
> - a magic page in kvmppc_mmu_book3s_64_xlate() and
> - guest real mode in kvmppc_handle_pagefault().
>
> For these ptes WIMG were 0 and pHyp failed on these causing a guest to
> stop in the very beginning at NIP=0x100 (due to bd9166ffe
> "KVM: PPC: Book3S PR: Exit KVM on failed mapping").
>
> This initializes WIMG to non-zero value HPTE_R_M. The value is chosen
> as (0x192 & HPTE_R_WIMG); 0x192 is a magic value from
> kvmppc_mmu_map_page().
>
> Fixes: 96df226 "KVM: PPC: Book3S PR: Preserve storage control bits"
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> ---
>
> This indeed fixes PR KVM + VFIO under pHyp but selection of HPTE_R_M
> is arguable.
>
The initial page fault at 0x100 on machine startup causes H_ENTER to fail in
pHyp with H_PARAMETER, as described in PAPR:
The hypervisor checks that the WIMG bits within the PTE are appropriate for the
physical page number else H_Parameter return. (For System Memory pages WIMG\010,
or, 1110 if the SAO option is enabled, and for IO pages WIMG\x01**.)
I'm not aware we care for SAO so HPTE_R_M looks like the only sensible choice,
or I'm missing something ?
Anyway, this patch allows to start a PR guest on PowerVM again.
Reviewed-by: Greg Kurz <groug@kaod.org>
and
Tested-by: Greg Kurz <groug@kaod.org>
> ---
> arch/powerpc/kvm/book3s_64_mmu.c | 1 +
> arch/powerpc/kvm/book3s_pr.c | 1 +
> 2 files changed, 2 insertions(+)
>
> diff --git a/arch/powerpc/kvm/book3s_64_mmu.c b/arch/powerpc/kvm/book3s_64_mmu.c
> index 29ebe2f..a93d719 100644
> --- a/arch/powerpc/kvm/book3s_64_mmu.c
> +++ b/arch/powerpc/kvm/book3s_64_mmu.c
> @@ -235,6 +235,7 @@ static int kvmppc_mmu_book3s_64_xlate(struct kvm_vcpu *vcpu, gva_t eaddr,
> gpte->may_read = true;
> gpte->may_write = true;
> gpte->page_size = MMU_PAGE_4K;
> + gpte->wimg = HPTE_R_M;
>
> return 0;
> }
> diff --git a/arch/powerpc/kvm/book3s_pr.c b/arch/powerpc/kvm/book3s_pr.c
> index 69a0944..0152efe 100644
> --- a/arch/powerpc/kvm/book3s_pr.c
> +++ b/arch/powerpc/kvm/book3s_pr.c
> @@ -557,6 +557,7 @@ int kvmppc_handle_pagefault(struct kvm_run *run, struct kvm_vcpu *vcpu,
> pte.eaddr = eaddr;
> pte.vpage = eaddr >> 12;
> pte.page_size = MMU_PAGE_64K;
> + pte.wimg = HPTE_R_M;
> }
>
> switch (kvmppc_get_msr(vcpu) & (MSR_DR|MSR_IR)) {
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [RFC PATCH kernel] KVM: PPC: Book3S PR: Fix WIMG handling under pHyp
2017-11-23 23:33 ` Greg Kurz
@ 2017-12-11 10:51 ` Alexander Graf
-1 siblings, 0 replies; 13+ messages in thread
From: Alexander Graf @ 2017-12-11 10:51 UTC (permalink / raw)
To: Greg Kurz, Alexey Kardashevskiy
Cc: David Gibson, linuxppc-dev, Paul Mackerras, kvm, kvm-ppc
On 24.11.17 00:33, Greg Kurz wrote:
> On Wed, 22 Nov 2017 14:42:21 +1100
> Alexey Kardashevskiy <aik@ozlabs.ru> wrote:
>
>> 96df226 "KVM: PPC: Book3S PR: Preserve storage control bits" added WIMG
>> bits preserving but it missed 2 special cases:
>> - a magic page in kvmppc_mmu_book3s_64_xlate() and
>> - guest real mode in kvmppc_handle_pagefault().
>>
>> For these ptes WIMG were 0 and pHyp failed on these causing a guest to
>> stop in the very beginning at NIP=0x100 (due to bd9166ffe
>> "KVM: PPC: Book3S PR: Exit KVM on failed mapping").
>>
>> This initializes WIMG to non-zero value HPTE_R_M. The value is chosen
>> as (0x192 & HPTE_R_WIMG); 0x192 is a magic value from
>> kvmppc_mmu_map_page().
>>
>> Fixes: 96df226 "KVM: PPC: Book3S PR: Preserve storage control bits"
>> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
>> ---
>>
>> This indeed fixes PR KVM + VFIO under pHyp but selection of HPTE_R_M
>> is arguable.
>>
>
> The initial page fault at 0x100 on machine startup causes H_ENTER to fail in
> pHyp with H_PARAMETER, as described in PAPR:
>
> The hypervisor checks that the WIMG bits within the PTE are appropriate for the
> physical page number else H_Parameter return. (For System Memory pages WIMG=0010,
> or, 1110 if the SAO option is enabled, and for IO pages WIMG=01**.)
>
> I'm not aware we care for SAO so HPTE_R_M looks like the only sensible choice,
> or I'm missing something ?
>
> Anyway, this patch allows to start a PR guest on PowerVM again.
>
> Reviewed-by: Greg Kurz <groug@kaod.org>
>
> and
>
> Tested-by: Greg Kurz <groug@kaod.org>
So doesn't that mean we should pick it up, mark it CC stable and push it
upstream?
Alex
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [RFC PATCH kernel] KVM: PPC: Book3S PR: Fix WIMG handling under pHyp
@ 2017-12-11 10:51 ` Alexander Graf
0 siblings, 0 replies; 13+ messages in thread
From: Alexander Graf @ 2017-12-11 10:51 UTC (permalink / raw)
To: Greg Kurz, Alexey Kardashevskiy
Cc: David Gibson, linuxppc-dev, Paul Mackerras, kvm, kvm-ppc
On 24.11.17 00:33, Greg Kurz wrote:
> On Wed, 22 Nov 2017 14:42:21 +1100
> Alexey Kardashevskiy <aik@ozlabs.ru> wrote:
>
>> 96df226 "KVM: PPC: Book3S PR: Preserve storage control bits" added WIMG
>> bits preserving but it missed 2 special cases:
>> - a magic page in kvmppc_mmu_book3s_64_xlate() and
>> - guest real mode in kvmppc_handle_pagefault().
>>
>> For these ptes WIMG were 0 and pHyp failed on these causing a guest to
>> stop in the very beginning at NIP=0x100 (due to bd9166ffe
>> "KVM: PPC: Book3S PR: Exit KVM on failed mapping").
>>
>> This initializes WIMG to non-zero value HPTE_R_M. The value is chosen
>> as (0x192 & HPTE_R_WIMG); 0x192 is a magic value from
>> kvmppc_mmu_map_page().
>>
>> Fixes: 96df226 "KVM: PPC: Book3S PR: Preserve storage control bits"
>> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
>> ---
>>
>> This indeed fixes PR KVM + VFIO under pHyp but selection of HPTE_R_M
>> is arguable.
>>
>
> The initial page fault at 0x100 on machine startup causes H_ENTER to fail in
> pHyp with H_PARAMETER, as described in PAPR:
>
> The hypervisor checks that the WIMG bits within the PTE are appropriate for the
> physical page number else H_Parameter return. (For System Memory pages WIMG\010,
> or, 1110 if the SAO option is enabled, and for IO pages WIMG\x01**.)
>
> I'm not aware we care for SAO so HPTE_R_M looks like the only sensible choice,
> or I'm missing something ?
>
> Anyway, this patch allows to start a PR guest on PowerVM again.
>
> Reviewed-by: Greg Kurz <groug@kaod.org>
>
> and
>
> Tested-by: Greg Kurz <groug@kaod.org>
So doesn't that mean we should pick it up, mark it CC stable and push it
upstream?
Alex
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [RFC PATCH kernel] KVM: PPC: Book3S PR: Fix WIMG handling under pHyp
2017-11-22 3:42 ` Alexey Kardashevskiy
@ 2018-01-08 5:29 ` Alexey Kardashevskiy
-1 siblings, 0 replies; 13+ messages in thread
From: Alexey Kardashevskiy @ 2018-01-08 5:29 UTC (permalink / raw)
To: Paul Mackerras; +Cc: linuxppc-dev, David Gibson, kvm-ppc, kvm, Alexander Graf
Paul,
I saw comments about the commit log but did this go to any tree eventually?
On 22/11/17 14:42, Alexey Kardashevskiy wrote:
> 96df226 "KVM: PPC: Book3S PR: Preserve storage control bits" added WIMG
> bits preserving but it missed 2 special cases:
> - a magic page in kvmppc_mmu_book3s_64_xlate() and
> - guest real mode in kvmppc_handle_pagefault().
>
> For these ptes WIMG were 0 and pHyp failed on these causing a guest to
> stop in the very beginning at NIP=0x100 (due to bd9166ffe
> "KVM: PPC: Book3S PR: Exit KVM on failed mapping").
>
> This initializes WIMG to non-zero value HPTE_R_M. The value is chosen
> as (0x192 & HPTE_R_WIMG); 0x192 is a magic value from
> kvmppc_mmu_map_page().
>
> Fixes: 96df226 "KVM: PPC: Book3S PR: Preserve storage control bits"
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> ---
>
> This indeed fixes PR KVM + VFIO under pHyp but selection of HPTE_R_M
> is arguable.
>
> ---
> arch/powerpc/kvm/book3s_64_mmu.c | 1 +
> arch/powerpc/kvm/book3s_pr.c | 1 +
> 2 files changed, 2 insertions(+)
>
> diff --git a/arch/powerpc/kvm/book3s_64_mmu.c b/arch/powerpc/kvm/book3s_64_mmu.c
> index 29ebe2f..a93d719 100644
> --- a/arch/powerpc/kvm/book3s_64_mmu.c
> +++ b/arch/powerpc/kvm/book3s_64_mmu.c
> @@ -235,6 +235,7 @@ static int kvmppc_mmu_book3s_64_xlate(struct kvm_vcpu *vcpu, gva_t eaddr,
> gpte->may_read = true;
> gpte->may_write = true;
> gpte->page_size = MMU_PAGE_4K;
> + gpte->wimg = HPTE_R_M;
>
> return 0;
> }
> diff --git a/arch/powerpc/kvm/book3s_pr.c b/arch/powerpc/kvm/book3s_pr.c
> index 69a0944..0152efe 100644
> --- a/arch/powerpc/kvm/book3s_pr.c
> +++ b/arch/powerpc/kvm/book3s_pr.c
> @@ -557,6 +557,7 @@ int kvmppc_handle_pagefault(struct kvm_run *run, struct kvm_vcpu *vcpu,
> pte.eaddr = eaddr;
> pte.vpage = eaddr >> 12;
> pte.page_size = MMU_PAGE_64K;
> + pte.wimg = HPTE_R_M;
> }
>
> switch (kvmppc_get_msr(vcpu) & (MSR_DR|MSR_IR)) {
>
--
Alexey
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [RFC PATCH kernel] KVM: PPC: Book3S PR: Fix WIMG handling under pHyp
@ 2018-01-08 5:29 ` Alexey Kardashevskiy
0 siblings, 0 replies; 13+ messages in thread
From: Alexey Kardashevskiy @ 2018-01-08 5:29 UTC (permalink / raw)
To: Paul Mackerras; +Cc: linuxppc-dev, David Gibson, kvm-ppc, kvm, Alexander Graf
Paul,
I saw comments about the commit log but did this go to any tree eventually?
On 22/11/17 14:42, Alexey Kardashevskiy wrote:
> 96df226 "KVM: PPC: Book3S PR: Preserve storage control bits" added WIMG
> bits preserving but it missed 2 special cases:
> - a magic page in kvmppc_mmu_book3s_64_xlate() and
> - guest real mode in kvmppc_handle_pagefault().
>
> For these ptes WIMG were 0 and pHyp failed on these causing a guest to
> stop in the very beginning at NIP=0x100 (due to bd9166ffe
> "KVM: PPC: Book3S PR: Exit KVM on failed mapping").
>
> This initializes WIMG to non-zero value HPTE_R_M. The value is chosen
> as (0x192 & HPTE_R_WIMG); 0x192 is a magic value from
> kvmppc_mmu_map_page().
>
> Fixes: 96df226 "KVM: PPC: Book3S PR: Preserve storage control bits"
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> ---
>
> This indeed fixes PR KVM + VFIO under pHyp but selection of HPTE_R_M
> is arguable.
>
> ---
> arch/powerpc/kvm/book3s_64_mmu.c | 1 +
> arch/powerpc/kvm/book3s_pr.c | 1 +
> 2 files changed, 2 insertions(+)
>
> diff --git a/arch/powerpc/kvm/book3s_64_mmu.c b/arch/powerpc/kvm/book3s_64_mmu.c
> index 29ebe2f..a93d719 100644
> --- a/arch/powerpc/kvm/book3s_64_mmu.c
> +++ b/arch/powerpc/kvm/book3s_64_mmu.c
> @@ -235,6 +235,7 @@ static int kvmppc_mmu_book3s_64_xlate(struct kvm_vcpu *vcpu, gva_t eaddr,
> gpte->may_read = true;
> gpte->may_write = true;
> gpte->page_size = MMU_PAGE_4K;
> + gpte->wimg = HPTE_R_M;
>
> return 0;
> }
> diff --git a/arch/powerpc/kvm/book3s_pr.c b/arch/powerpc/kvm/book3s_pr.c
> index 69a0944..0152efe 100644
> --- a/arch/powerpc/kvm/book3s_pr.c
> +++ b/arch/powerpc/kvm/book3s_pr.c
> @@ -557,6 +557,7 @@ int kvmppc_handle_pagefault(struct kvm_run *run, struct kvm_vcpu *vcpu,
> pte.eaddr = eaddr;
> pte.vpage = eaddr >> 12;
> pte.page_size = MMU_PAGE_64K;
> + pte.wimg = HPTE_R_M;
> }
>
> switch (kvmppc_get_msr(vcpu) & (MSR_DR|MSR_IR)) {
>
--
Alexey
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [RFC PATCH kernel] KVM: PPC: Book3S PR: Fix WIMG handling under pHyp
2017-11-22 3:42 ` Alexey Kardashevskiy
@ 2018-01-11 9:56 ` Paul Mackerras
-1 siblings, 0 replies; 13+ messages in thread
From: Paul Mackerras @ 2018-01-11 9:56 UTC (permalink / raw)
To: Alexey Kardashevskiy
Cc: linuxppc-dev, David Gibson, kvm-ppc, kvm, Alexander Graf
On Wed, Nov 22, 2017 at 02:42:21PM +1100, Alexey Kardashevskiy wrote:
> 96df226 "KVM: PPC: Book3S PR: Preserve storage control bits" added WIMG
> bits preserving but it missed 2 special cases:
> - a magic page in kvmppc_mmu_book3s_64_xlate() and
> - guest real mode in kvmppc_handle_pagefault().
>
> For these ptes WIMG were 0 and pHyp failed on these causing a guest to
> stop in the very beginning at NIP=0x100 (due to bd9166ffe
> "KVM: PPC: Book3S PR: Exit KVM on failed mapping").
>
> This initializes WIMG to non-zero value HPTE_R_M. The value is chosen
> as (0x192 & HPTE_R_WIMG); 0x192 is a magic value from
> kvmppc_mmu_map_page().
>
> Fixes: 96df226 "KVM: PPC: Book3S PR: Preserve storage control bits"
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Thanks, applied to my kvm-ppc-fixes branch, with an updated commit
message, fixes: tag, and cc:stable@vger.kernel.org.
Paul.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [RFC PATCH kernel] KVM: PPC: Book3S PR: Fix WIMG handling under pHyp
@ 2018-01-11 9:56 ` Paul Mackerras
0 siblings, 0 replies; 13+ messages in thread
From: Paul Mackerras @ 2018-01-11 9:56 UTC (permalink / raw)
To: Alexey Kardashevskiy
Cc: linuxppc-dev, David Gibson, kvm-ppc, kvm, Alexander Graf
On Wed, Nov 22, 2017 at 02:42:21PM +1100, Alexey Kardashevskiy wrote:
> 96df226 "KVM: PPC: Book3S PR: Preserve storage control bits" added WIMG
> bits preserving but it missed 2 special cases:
> - a magic page in kvmppc_mmu_book3s_64_xlate() and
> - guest real mode in kvmppc_handle_pagefault().
>
> For these ptes WIMG were 0 and pHyp failed on these causing a guest to
> stop in the very beginning at NIP=0x100 (due to bd9166ffe
> "KVM: PPC: Book3S PR: Exit KVM on failed mapping").
>
> This initializes WIMG to non-zero value HPTE_R_M. The value is chosen
> as (0x192 & HPTE_R_WIMG); 0x192 is a magic value from
> kvmppc_mmu_map_page().
>
> Fixes: 96df226 "KVM: PPC: Book3S PR: Preserve storage control bits"
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Thanks, applied to my kvm-ppc-fixes branch, with an updated commit
message, fixes: tag, and cc:stable@vger.kernel.org.
Paul.
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2018-01-11 10:01 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-22 3:42 [RFC PATCH kernel] KVM: PPC: Book3S PR: Fix WIMG handling under pHyp Alexey Kardashevskiy
2017-11-22 3:42 ` Alexey Kardashevskiy
2017-11-22 15:02 ` Alexander Graf
2017-11-22 15:02 ` Alexander Graf
2017-11-23 23:33 ` Greg Kurz
2017-11-23 23:33 ` Greg Kurz
2017-11-23 23:33 ` Greg Kurz
2017-12-11 10:51 ` Alexander Graf
2017-12-11 10:51 ` Alexander Graf
2018-01-08 5:29 ` Alexey Kardashevskiy
2018-01-08 5:29 ` Alexey Kardashevskiy
2018-01-11 9:56 ` Paul Mackerras
2018-01-11 9:56 ` Paul Mackerras
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.