diff mbox series

[v2,for-2.12,08/16] s390x/tcg: don't exit the cpu loop in s390_cpu_virt_mem_rw()

Message ID 20171129202701.16117-9-david@redhat.com
State New
Headers show
Series s390x/tcg: cleanup and fix program interrupts | expand

Commit Message

David Hildenbrand Nov. 29, 2017, 8:26 p.m. UTC
s390_cpu_virt_mem_rw() must always return, so callers can react on
an exception (e.g. see ioinst_handle_stcrw()).

Therefore, using program_interrupt() is wrong. Fix that up.

Signed-off-by: David Hildenbrand <david@redhat.com>
---
 target/s390x/mmu_helper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Richard Henderson Nov. 29, 2017, 9:01 p.m. UTC | #1
On 11/29/2017 08:26 PM, David Hildenbrand wrote:
> s390_cpu_virt_mem_rw() must always return, so callers can react on
> an exception (e.g. see ioinst_handle_stcrw()).
> 
> Therefore, using program_interrupt() is wrong. Fix that up.
> 
> Signed-off-by: David Hildenbrand <david@redhat.com>
> ---
>  target/s390x/mmu_helper.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~
Thomas Huth Nov. 30, 2017, 11:39 a.m. UTC | #2
On 29.11.2017 21:26, David Hildenbrand wrote:
> s390_cpu_virt_mem_rw() must always return, so callers can react on
> an exception (e.g. see ioinst_handle_stcrw()).
> 
> Therefore, using program_interrupt() is wrong. Fix that up.
> 
> Signed-off-by: David Hildenbrand <david@redhat.com>
> ---
>  target/s390x/mmu_helper.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/target/s390x/mmu_helper.c b/target/s390x/mmu_helper.c
> index dbe2f511f8..2c7f3d7d95 100644
> --- a/target/s390x/mmu_helper.c
> +++ b/target/s390x/mmu_helper.c
> @@ -459,7 +459,7 @@ static int translate_pages(S390CPU *cpu, vaddr addr, int nr_pages,
>          }
>          if (!address_space_access_valid(&address_space_memory, pages[i],
>                                          TARGET_PAGE_SIZE, is_write)) {
> -            program_interrupt(env, PGM_ADDRESSING, ILEN_AUTO);
> +            trigger_pgm_exception(env, PGM_ADDRESSING, ILEN_AUTO);
>              return -EFAULT;
>          }
>          addr += TARGET_PAGE_SIZE;

Is that still right when running with KVM? I think the exception will
then silently be ignored instead?

 Thomas
David Hildenbrand Nov. 30, 2017, 11:57 a.m. UTC | #3
On 30.11.2017 12:39, Thomas Huth wrote:
> On 29.11.2017 21:26, David Hildenbrand wrote:
>> s390_cpu_virt_mem_rw() must always return, so callers can react on
>> an exception (e.g. see ioinst_handle_stcrw()).
>>
>> Therefore, using program_interrupt() is wrong. Fix that up.
>>
>> Signed-off-by: David Hildenbrand <david@redhat.com>
>> ---
>>  target/s390x/mmu_helper.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/target/s390x/mmu_helper.c b/target/s390x/mmu_helper.c
>> index dbe2f511f8..2c7f3d7d95 100644
>> --- a/target/s390x/mmu_helper.c
>> +++ b/target/s390x/mmu_helper.c
>> @@ -459,7 +459,7 @@ static int translate_pages(S390CPU *cpu, vaddr addr, int nr_pages,
>>          }
>>          if (!address_space_access_valid(&address_space_memory, pages[i],
>>                                          TARGET_PAGE_SIZE, is_write)) {
>> -            program_interrupt(env, PGM_ADDRESSING, ILEN_AUTO);
>> +            trigger_pgm_exception(env, PGM_ADDRESSING, ILEN_AUTO);
>>              return -EFAULT;
>>          }
>>          addr += TARGET_PAGE_SIZE;
> 
> Is that still right when running with KVM? I think the exception will
> then silently be ignored instead?

Good point (for older KVM). And ugly.

if (kvm_enabled()) {
	kvm_s390_program_interrupt...
} else {
	trigger_pgm_exception(env, PGM_ADDRESSING, ILEN_AUTO);
}

> 
>  Thomas
>
Cornelia Huck Nov. 30, 2017, 12:11 p.m. UTC | #4
On Thu, 30 Nov 2017 12:57:00 +0100
David Hildenbrand <david@redhat.com> wrote:

> On 30.11.2017 12:39, Thomas Huth wrote:
> > On 29.11.2017 21:26, David Hildenbrand wrote:  
> >> s390_cpu_virt_mem_rw() must always return, so callers can react on
> >> an exception (e.g. see ioinst_handle_stcrw()).
> >>
> >> Therefore, using program_interrupt() is wrong. Fix that up.
> >>
> >> Signed-off-by: David Hildenbrand <david@redhat.com>
> >> ---
> >>  target/s390x/mmu_helper.c | 2 +-
> >>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/target/s390x/mmu_helper.c b/target/s390x/mmu_helper.c
> >> index dbe2f511f8..2c7f3d7d95 100644
> >> --- a/target/s390x/mmu_helper.c
> >> +++ b/target/s390x/mmu_helper.c
> >> @@ -459,7 +459,7 @@ static int translate_pages(S390CPU *cpu, vaddr addr, int nr_pages,
> >>          }
> >>          if (!address_space_access_valid(&address_space_memory, pages[i],
> >>                                          TARGET_PAGE_SIZE, is_write)) {
> >> -            program_interrupt(env, PGM_ADDRESSING, ILEN_AUTO);
> >> +            trigger_pgm_exception(env, PGM_ADDRESSING, ILEN_AUTO);
> >>              return -EFAULT;
> >>          }
> >>          addr += TARGET_PAGE_SIZE;  
> > 
> > Is that still right when running with KVM? I think the exception will
> > then silently be ignored instead?  
> 
> Good point (for older KVM). And ugly.
> 
> if (kvm_enabled()) {
> 	kvm_s390_program_interrupt...
> } else {
> 	trigger_pgm_exception(env, PGM_ADDRESSING, ILEN_AUTO);
> }

Maybe add a comment that this is only for old kernels that do not
support the mem op interface?
diff mbox series

Patch

diff --git a/target/s390x/mmu_helper.c b/target/s390x/mmu_helper.c
index dbe2f511f8..2c7f3d7d95 100644
--- a/target/s390x/mmu_helper.c
+++ b/target/s390x/mmu_helper.c
@@ -459,7 +459,7 @@  static int translate_pages(S390CPU *cpu, vaddr addr, int nr_pages,
         }
         if (!address_space_access_valid(&address_space_memory, pages[i],
                                         TARGET_PAGE_SIZE, is_write)) {
-            program_interrupt(env, PGM_ADDRESSING, ILEN_AUTO);
+            trigger_pgm_exception(env, PGM_ADDRESSING, ILEN_AUTO);
             return -EFAULT;
         }
         addr += TARGET_PAGE_SIZE;