Message ID | 20191024114059.102802-25-frankja@linux.ibm.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | KVM: s390: Add support for protected VMs | expand |
On 24/10/2019 13.40, Janosch Frank wrote: > STHYI data has to go through the bounce buffer. > > Signed-off-by: Janosch Frank <frankja@linux.ibm.com> > --- > arch/s390/kvm/intercept.c | 15 ++++++++++----- > 1 file changed, 10 insertions(+), 5 deletions(-) > > diff --git a/arch/s390/kvm/intercept.c b/arch/s390/kvm/intercept.c > index 510b1dee3320..37cb62bc261b 100644 > --- a/arch/s390/kvm/intercept.c > +++ b/arch/s390/kvm/intercept.c > @@ -391,7 +391,7 @@ int handle_sthyi(struct kvm_vcpu *vcpu) > goto out; > } > > - if (addr & ~PAGE_MASK) > + if (!kvm_s390_pv_is_protected(vcpu->kvm) && (addr & ~PAGE_MASK)) > return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION); > > sctns = (void *)get_zeroed_page(GFP_KERNEL); > @@ -402,10 +402,15 @@ int handle_sthyi(struct kvm_vcpu *vcpu) > > out: > if (!cc) { > - r = write_guest(vcpu, addr, reg2, sctns, PAGE_SIZE); > - if (r) { > - free_page((unsigned long)sctns); > - return kvm_s390_inject_prog_cond(vcpu, r); > + if (kvm_s390_pv_is_protected(vcpu->kvm)) { > + memcpy((void *)vcpu->arch.sie_block->sidad, sctns, sidad & PAGE_MASK, just to be sure? > + PAGE_SIZE); > + } else { > + r = write_guest(vcpu, addr, reg2, sctns, PAGE_SIZE); > + if (r) { > + free_page((unsigned long)sctns); > + return kvm_s390_inject_prog_cond(vcpu, r); > + } > } > } > > With "& PAGE_MASK": Reviewed-by: Thomas Huth <thuth@redhat.com>
On 11/15/19 9:04 AM, Thomas Huth wrote: > On 24/10/2019 13.40, Janosch Frank wrote: >> STHYI data has to go through the bounce buffer. >> >> Signed-off-by: Janosch Frank <frankja@linux.ibm.com> >> --- >> arch/s390/kvm/intercept.c | 15 ++++++++++----- >> 1 file changed, 10 insertions(+), 5 deletions(-) >> >> diff --git a/arch/s390/kvm/intercept.c b/arch/s390/kvm/intercept.c >> index 510b1dee3320..37cb62bc261b 100644 >> --- a/arch/s390/kvm/intercept.c >> +++ b/arch/s390/kvm/intercept.c >> @@ -391,7 +391,7 @@ int handle_sthyi(struct kvm_vcpu *vcpu) >> goto out; >> } >> >> - if (addr & ~PAGE_MASK) >> + if (!kvm_s390_pv_is_protected(vcpu->kvm) && (addr & ~PAGE_MASK)) >> return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION); >> >> sctns = (void *)get_zeroed_page(GFP_KERNEL); >> @@ -402,10 +402,15 @@ int handle_sthyi(struct kvm_vcpu *vcpu) >> >> out: >> if (!cc) { >> - r = write_guest(vcpu, addr, reg2, sctns, PAGE_SIZE); >> - if (r) { >> - free_page((unsigned long)sctns); >> - return kvm_s390_inject_prog_cond(vcpu, r); >> + if (kvm_s390_pv_is_protected(vcpu->kvm)) { >> + memcpy((void *)vcpu->arch.sie_block->sidad, sctns, > > sidad & PAGE_MASK, just to be sure? How about a macro or just saving the pointer in an arch struct? > >> + PAGE_SIZE); >> + } else { >> + r = write_guest(vcpu, addr, reg2, sctns, PAGE_SIZE); >> + if (r) { >> + free_page((unsigned long)sctns); >> + return kvm_s390_inject_prog_cond(vcpu, r); >> + } >> } >> } >> >> > > With "& PAGE_MASK": > > Reviewed-by: Thomas Huth <thuth@redhat.com> >
On 15/11/2019 11.16, Janosch Frank wrote: > On 11/15/19 9:04 AM, Thomas Huth wrote: >> On 24/10/2019 13.40, Janosch Frank wrote: >>> STHYI data has to go through the bounce buffer. >>> >>> Signed-off-by: Janosch Frank <frankja@linux.ibm.com> >>> --- >>> arch/s390/kvm/intercept.c | 15 ++++++++++----- >>> 1 file changed, 10 insertions(+), 5 deletions(-) >>> >>> diff --git a/arch/s390/kvm/intercept.c b/arch/s390/kvm/intercept.c >>> index 510b1dee3320..37cb62bc261b 100644 >>> --- a/arch/s390/kvm/intercept.c >>> +++ b/arch/s390/kvm/intercept.c >>> @@ -391,7 +391,7 @@ int handle_sthyi(struct kvm_vcpu *vcpu) >>> goto out; >>> } >>> >>> - if (addr & ~PAGE_MASK) >>> + if (!kvm_s390_pv_is_protected(vcpu->kvm) && (addr & ~PAGE_MASK)) >>> return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION); >>> >>> sctns = (void *)get_zeroed_page(GFP_KERNEL); >>> @@ -402,10 +402,15 @@ int handle_sthyi(struct kvm_vcpu *vcpu) >>> >>> out: >>> if (!cc) { >>> - r = write_guest(vcpu, addr, reg2, sctns, PAGE_SIZE); >>> - if (r) { >>> - free_page((unsigned long)sctns); >>> - return kvm_s390_inject_prog_cond(vcpu, r); >>> + if (kvm_s390_pv_is_protected(vcpu->kvm)) { >>> + memcpy((void *)vcpu->arch.sie_block->sidad, sctns, >> >> sidad & PAGE_MASK, just to be sure? > > How about a macro or just saving the pointer in an arch struct? Sounds fine, too. I think I'd personally slightly prefer a macro. Thomas
diff --git a/arch/s390/kvm/intercept.c b/arch/s390/kvm/intercept.c index 510b1dee3320..37cb62bc261b 100644 --- a/arch/s390/kvm/intercept.c +++ b/arch/s390/kvm/intercept.c @@ -391,7 +391,7 @@ int handle_sthyi(struct kvm_vcpu *vcpu) goto out; } - if (addr & ~PAGE_MASK) + if (!kvm_s390_pv_is_protected(vcpu->kvm) && (addr & ~PAGE_MASK)) return kvm_s390_inject_program_int(vcpu, PGM_SPECIFICATION); sctns = (void *)get_zeroed_page(GFP_KERNEL); @@ -402,10 +402,15 @@ int handle_sthyi(struct kvm_vcpu *vcpu) out: if (!cc) { - r = write_guest(vcpu, addr, reg2, sctns, PAGE_SIZE); - if (r) { - free_page((unsigned long)sctns); - return kvm_s390_inject_prog_cond(vcpu, r); + if (kvm_s390_pv_is_protected(vcpu->kvm)) { + memcpy((void *)vcpu->arch.sie_block->sidad, sctns, + PAGE_SIZE); + } else { + r = write_guest(vcpu, addr, reg2, sctns, PAGE_SIZE); + if (r) { + free_page((unsigned long)sctns); + return kvm_s390_inject_prog_cond(vcpu, r); + } } }
STHYI data has to go through the bounce buffer. Signed-off-by: Janosch Frank <frankja@linux.ibm.com> --- arch/s390/kvm/intercept.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)