qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Thomas Huth <thuth@redhat.com>, qemu-devel@nongnu.org
Cc: Janosch Frank <frankja@linux.ibm.com>,
	Cornelia Huck <cohuck@redhat.com>,
	Halil Pasic <pasic@linux.ibm.com>,
	Christian Borntraeger <borntraeger@de.ibm.com>,
	qemu-s390x@nongnu.org, Richard Henderson <rth@twiddle.net>
Subject: Re: [PATCH v3 7/7] s390x/mmu: Convert to non-recursive page table walk
Date: Tue, 1 Oct 2019 10:17:17 +0200	[thread overview]
Message-ID: <efeaf2e2-2bb7-97a0-b76b-af21fa197b4d@redhat.com> (raw)
In-Reply-To: <b6ad5c2a-bacc-9b41-d141-c8da2fb4ae8d@redhat.com>


>>          break;
>>      case ASCE_TYPE_SEGMENT:
>>          if (VADDR_REGION1_TX(vaddr) || VADDR_REGION2_TX(vaddr) ||
>> @@ -253,11 +164,112 @@ static int mmu_translate_asce(CPUS390XState *env, target_ulong vaddr,
>>          if (VADDR_SEGMENT_TL(vaddr) > asce_tl) {
>>              return PGM_SEGMENT_TRANS;
>>          }
>> +        gaddr += VADDR_SEGMENT_TX(vaddr) * 8;
>> +        break;
>> +    default:
>> +        g_assert_not_reached();
> 
> As far as I can see, all four cases are handled above, so this default
> case should really not be necessary here.

Yes, can drop.

> 
>> +    }
>> +
>> +    switch (asce & ASCE_TYPE_MASK) {
>> +    case ASCE_TYPE_REGION1:
>> +        if (!read_table_entry(env, gaddr, &entry)) {
>> +            return PGM_ADDRESSING;
>> +        }
>> +        if (entry & REGION_ENTRY_I) {
>> +            return PGM_REG_FIRST_TRANS;
>> +        }
>> +        if ((entry & REGION_ENTRY_TT) != REGION_ENTRY_TT_REGION1) {
>> +            return PGM_TRANS_SPEC;
>> +        }
>> +        if (VADDR_REGION2_TL(vaddr) < (entry & REGION_ENTRY_TF) >> 6 ||
>> +            VADDR_REGION2_TL(vaddr) > (entry & REGION_ENTRY_TL)) {
>> +            return PGM_REG_SEC_TRANS;
>> +        }
>> +        if (edat1 && (entry & REGION_ENTRY_P)) {
>> +            *flags &= ~PAGE_WRITE;
>> +        }
>> +        gaddr = (entry & REGION_ENTRY_ORIGIN) + VADDR_REGION2_TX(vaddr) * 8;
>> +        /* fall through */
>> +    case ASCE_TYPE_REGION2:
>> +        if (!read_table_entry(env, gaddr, &entry)) {
>> +            return PGM_ADDRESSING;
>> +        }
>> +        if (entry & REGION_ENTRY_I) {
>> +            return PGM_REG_SEC_TRANS;
>> +        }
>> +        if ((entry & REGION_ENTRY_TT) != REGION_ENTRY_TT_REGION2) {
>> +            return PGM_TRANS_SPEC;
>> +        }
>> +        if (VADDR_REGION3_TL(vaddr) < (entry & REGION_ENTRY_TF) >> 6 ||
>> +            VADDR_REGION3_TL(vaddr) > (entry & REGION_ENTRY_TL)) {
>> +            return PGM_REG_THIRD_TRANS;
>> +        }
>> +        if (edat1 && (entry & REGION_ENTRY_P)) {
>> +            *flags &= ~PAGE_WRITE;
>> +        }
>> +        gaddr = (entry & REGION_ENTRY_ORIGIN) + VADDR_REGION3_TX(vaddr) * 8;
>> +        /* fall through */
>> +    case ASCE_TYPE_REGION3:
>> +        if (!read_table_entry(env, gaddr, &entry)) {
>> +            return PGM_ADDRESSING;
>> +        }
>> +        if (entry & REGION_ENTRY_I) {
>> +            return PGM_REG_THIRD_TRANS;
>> +        }
>> +        if ((entry & REGION_ENTRY_TT) != REGION_ENTRY_TT_REGION3) {
>> +            return PGM_TRANS_SPEC;
>> +        }
>> +        if (edat1 && (entry & REGION_ENTRY_P)) {
>> +            *flags &= ~PAGE_WRITE;
>> +        }
> 
> Shouldn't that check be done below the next if-statement?

Does it matter? The flags are irrelevant in case we return an exception,
so the order shouldn't matter.

> 
>> +        if (VADDR_SEGMENT_TL(vaddr) < (entry & REGION_ENTRY_TF) >> 6 ||
>> +            VADDR_SEGMENT_TL(vaddr) > (entry & REGION_ENTRY_TL)) {
>> +            return PGM_SEGMENT_TRANS;
>> +        }
>> +        gaddr = (entry & REGION_ENTRY_ORIGIN) + VADDR_SEGMENT_TX(vaddr) * 8;
>> +        /* fall through */
>> +    case ASCE_TYPE_SEGMENT:
>> +        if (!read_table_entry(env, gaddr, &entry)) {
>> +            return PGM_ADDRESSING;
>> +        }
>> +        if (entry & SEGMENT_ENTRY_I) {
>> +            return PGM_SEGMENT_TRANS;
>> +        }
>> +        if ((entry & SEGMENT_ENTRY_TT) != SEGMENT_ENTRY_TT_SEGMENT) {
>> +            return PGM_TRANS_SPEC;
>> +        }
>> +        if ((entry & SEGMENT_ENTRY_CS) && asce_p) {
>> +            return PGM_TRANS_SPEC;
>> +        }
>> +        if (entry & SEGMENT_ENTRY_P) {
>> +            *flags &= ~PAGE_WRITE;
>> +        }
>> +        if (edat1 && (entry & SEGMENT_ENTRY_FC)) {
>> +            *raddr = (entry & SEGMENT_ENTRY_SFAA) |
>> +                     (vaddr & ~SEGMENT_ENTRY_SFAA);
>> +            return 0;
>> +        }
>> +        gaddr = (entry & SEGMENT_ENTRY_ORIGIN) + VADDR_PAGE_TX(vaddr) * 8;
>>          break;
>> +    default:
>> +        g_assert_not_reached();
> 
> That default case could be dropped, too.

Yes, can do.

Thanks!


-- 

Thanks,

David / dhildenb


  reply	other threads:[~2019-10-01  8:18 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-27  9:58 [PATCH v3 0/7] s390x/mmu: DAT translation rewrite David Hildenbrand
2019-09-27  9:58 ` [PATCH v3 1/7] s390x/mmu: Drop debug logging from MMU code David Hildenbrand
2019-09-27  9:58 ` [PATCH v3 2/7] s390x/mmu: Move DAT protection handling out of mmu_translate_asce() David Hildenbrand
2019-09-27  9:58 ` [PATCH v3 3/7] s390x/mmu: Inject DAT exceptions from a single place David Hildenbrand
2019-09-27  9:58 ` [PATCH v3 4/7] s390x/mmu: Inject PGM_ADDRESSING on boguous table addresses David Hildenbrand
2019-09-27 17:58   ` Richard Henderson
2019-09-27  9:58 ` [PATCH v3 5/7] s390x/mmu: Use TARGET_PAGE_MASK in mmu_translate_pte() David Hildenbrand
2019-09-27  9:58 ` [PATCH v3 6/7] s390x/mmu: DAT table definition overhaul David Hildenbrand
2019-09-27 17:59   ` Richard Henderson
2019-10-01  4:54   ` Thomas Huth
2019-10-01  7:29     ` David Hildenbrand
2019-09-27  9:58 ` [PATCH v3 7/7] s390x/mmu: Convert to non-recursive page table walk David Hildenbrand
2019-09-27 18:00   ` Richard Henderson
2019-10-01  8:15   ` Thomas Huth
2019-10-01  8:17     ` David Hildenbrand [this message]
2019-10-01  8:23       ` Thomas Huth
2019-10-01  8:24         ` David Hildenbrand

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=efeaf2e2-2bb7-97a0-b76b-af21fa197b4d@redhat.com \
    --to=david@redhat.com \
    --cc=borntraeger@de.ibm.com \
    --cc=cohuck@redhat.com \
    --cc=frankja@linux.ibm.com \
    --cc=pasic@linux.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-s390x@nongnu.org \
    --cc=rth@twiddle.net \
    --cc=thuth@redhat.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).