xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Ian Campbell <ian.campbell@citrix.com>
To: Tamas K Lengyel <tklengyel@sec.in.tum.de>
Cc: tim@xen.org, julien.grall@linaro.org, ian.jackson@eu.citrix.com,
	xen-devel@lists.xen.org, stefano.stabellini@citrix.com,
	andres@lagarcavilla.org, jbeulich@suse.com,
	dgdegra@tycho.nsa.gov
Subject: Re: [PATCH for-4.5 v6 13/17] xen/arm: Data abort exception (R/W) mem_events.
Date: Thu, 18 Sep 2014 19:54:36 +0100	[thread overview]
Message-ID: <1411066476.1920.25.camel@citrix.com> (raw)
In-Reply-To: <1410789775-24197-14-git-send-email-tklengyel@sec.in.tum.de>

On Mon, 2014-09-15 at 16:02 +0200, Tamas K Lengyel wrote:

> -        if ( is_mapping_aligned(*addr, end_gpaddr, 0, level_size) )
> +        if ( level < 3 && p2m_access_rwx != a )
> +        {
> +            /* We create only 4k pages when mem_access is in use. */

I wonder if it might turn out cleaner to integrate this check into
is_mapping_aligned (which really is more of a "can we use a superpage"
function).

i.e.
        /* mem access cannot use super pages */
        if ( a != p2m_access_rwx && level_size != THIRD_SIZE )
                return false;

> +        }
> +        else if ( is_mapping_aligned(*addr, end_gpaddr, 0, level_size) )
>          {
>              struct page_info *page;
>  
>              page = alloc_domheap_pages(d, level_shift - PAGE_SHIFT, 0);
>              if ( page )
>              {
> +                if ( 3 == level )

Please write the conditionals the other way around.

> +                {
> +                    rc = p2m_mem_access_radix_set(p2m, paddr_to_pfn(*addr), a);
> +                    if ( rc < 0 )
> +                    {
> +                        free_domheap_page(page);
> +                        return rc;
> +                    }

> +                }
> +                else
> +                {
> +                    a = p2m_access_rwx;
> +                }

You have this else clause twice, I think you could pull it up to the
head of the function, or perhaps even into the caller.
> @@ -627,15 +741,11 @@ static int apply_one_level(struct domain *d,
>                   * and descend.
>                   */
>                  *flush = true;
> -                rc = p2m_create_table(d, entry,
> -                                      level_shift - PAGE_SHIFT, flush_cache);
> +                rc = p2m_shatter_page(d, entry, level, level_shift, flush_cache);
> +

Please keep the error handling if snuggled against the function, (i.e.
drop the additional blank line) here and in at least one other place
which you've changed.

> @@ -704,6 +815,49 @@ static int apply_one_level(struct domain *d,
>              *addr += PAGE_SIZE;
>              return P2M_ONE_PROGRESS_NOP;
>          }
> +
> +    case MEMACCESS:
> +        if ( level < 3 )
> +        {
> +            if ( !p2m_valid(orig_pte) )
> +            {
> +                *addr += level_size;
> +                return P2M_ONE_PROGRESS_NOP;
> +            }
> +
> +            /* Shatter large pages as we descend */
> +            if ( p2m_mapping(orig_pte) )
> +            {
> +                rc = p2m_shatter_page(d, entry, level, level_shift, flush_cache);
> +
> +                if ( rc < 0 )
> +                    return rc;
> +            } /* else: an existing table mapping -> descend */
> +
> +            return P2M_ONE_DESCEND;
> +        }
> +        else
> +        {
> +            pte = orig_pte;
> +
> +            if ( !p2m_table(pte) )
> +                pte.bits = 0;
> +
> +            if ( p2m_valid(pte) )
> +            {
> +                ASSERT(pte.p2m.type != p2m_invalid);
> +
> +                rc = p2m_mem_access_radix_set(p2m, paddr_to_pfn(*addr), a);
> +                if ( rc < 0 )
> +                    return rc;
> +
> +                p2m_set_permission(&pte, pte.p2m.type, a);

I think this function can always make use of pte.p2m.type itself rather
than receiving it as a parameter. The other caller passes "t" but has
already assigned that to pte.p2m.type as well.
>  
> -    rc = gva_to_ipa(info.gva, &info.gpa);
> -    if ( rc == -EFAULT )
> +    switch ( dabt.dfsc )
> +    {
> +    case DABT_DFSC_PERMISSION_1:
> +    case DABT_DFSC_PERMISSION_2:
> +    case DABT_DFSC_PERMISSION_3:

Eventually this will need to handle level 0 too. Would it work to mask
out the level bits and check the remainder against the common bit
pattern?

> +/* Data abort data fetch status codes */
> +enum dabt_dfsc {
> +    DABT_DFSC_ADDR_SIZE_0       = 0b000000,

Unfortunately I think 0b... is a gcc extension and not standard C
(please correct me if I'm wrong). In which case we should probably avoid
it and use hex instead.

Actually, isn't this partially duplicating the existing FSC_* defines?
We should either use those here or move the existing users over to the
new scheme.

Ian.

  parent reply	other threads:[~2014-09-18 18:54 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-15 14:02 [PATCH for-4.5 v6 00/17] Mem_event and mem_access for ARM Tamas K Lengyel
2014-09-15 14:02 ` [PATCH for-4.5 v6 01/17] xen: Relocate mem_access and mem_event into common Tamas K Lengyel
2014-09-15 14:02 ` [PATCH for-4.5 v6 02/17] xen: Relocate p2m_mem_access_resume to mem_access common Tamas K Lengyel
2014-09-15 14:02 ` [PATCH for-4.5 v6 03/17] xen: Relocate struct npfec definition into common Tamas K Lengyel
2014-09-15 14:02 ` [PATCH for-4.5 v6 04/17] xen: Relocate mem_event_op domctl and access_op memop " Tamas K Lengyel
2014-09-15 14:02 ` [PATCH for-4.5 v6 05/17] x86/p2m: Typo fix for spelling ambiguous Tamas K Lengyel
2014-09-15 14:02 ` [PATCH for-4.5 v6 06/17] xen/mem_event: Clean out superfluous white-spaces Tamas K Lengyel
2014-09-15 14:02 ` [PATCH for-4.5 v6 07/17] xen/mem_event: Relax error condition on debug builds Tamas K Lengyel
2014-09-15 14:02 ` [PATCH for-4.5 v6 08/17] xen/mem_event: Abstract architecture specific sanity checks Tamas K Lengyel
2014-09-15 14:02 ` [PATCH for-4.5 v6 09/17] xen/mem_access: Abstract architecture specific sanity check Tamas K Lengyel
2014-09-15 14:02 ` [PATCH for-4.5 v6 10/17] xen/arm: p2m type definitions and changes Tamas K Lengyel
2014-09-15 22:35   ` Ian Campbell
2014-09-16  8:49     ` Tamas K Lengyel
2014-09-16 13:27       ` Ian Campbell
2014-09-16 20:38         ` Julien Grall
2014-09-16 21:52           ` Tamas K Lengyel
2014-09-15 14:02 ` [PATCH for-4.5 v6 11/17] xen/arm: Add set access required domctl Tamas K Lengyel
2014-09-15 22:37   ` Ian Campbell
2014-09-16  8:37     ` Tamas K Lengyel
2014-09-15 22:38   ` Ian Campbell
2014-09-16  8:33     ` Tamas K Lengyel
2014-09-16 13:25       ` Ian Campbell
2014-09-15 14:02 ` [PATCH for-4.5 v6 12/17] xen/arm: Implement domain_get_maximum_gpfn Tamas K Lengyel
2014-09-15 22:39   ` Ian Campbell
2014-09-16  8:02     ` Tamas K Lengyel
2014-09-16 16:44       ` Ian Campbell
2014-09-16 17:09         ` Tamas K Lengyel
2014-09-15 14:02 ` [PATCH for-4.5 v6 13/17] xen/arm: Data abort exception (R/W) mem_events Tamas K Lengyel
2014-09-15 22:53   ` Ian Campbell
     [not found]     ` <CAErYnshu0vJJMxWwu4eo2MZf=q_g2H123p6VUk_4a9f12vYLjg@mail.gmail.com>
2014-09-16 10:07       ` Tamas K Lengyel
2014-09-16 16:50         ` Ian Campbell
2014-09-16 17:08           ` Tamas K Lengyel
2014-09-18 18:54   ` Ian Campbell [this message]
2014-09-18 20:09     ` Tamas K Lengyel
2014-09-19  9:05       ` Tamas K Lengyel
2014-09-22  9:11         ` Ian Campbell
2014-09-22 17:18           ` Tamas K Lengyel
2014-09-15 14:02 ` [PATCH for-4.5 v6 14/17] xen/arm: Instruction prefetch abort (X) mem_event handling Tamas K Lengyel
2014-09-18 18:59   ` Ian Campbell
2014-09-18 20:12     ` Tamas K Lengyel
2014-09-15 14:02 ` [PATCH for-4.5 v6 15/17] xen/arm: Enable the compilation of mem_access and mem_event on ARM Tamas K Lengyel
2014-09-15 14:02 ` [PATCH for-4.5 v6 16/17] tools/libxc: Allocate magic page for mem access " Tamas K Lengyel
2014-09-15 14:02 ` [PATCH for-4.5 v6 17/17] tools/tests: Enable xen-access " Tamas K Lengyel
2014-09-18 19:02   ` Ian Campbell
2014-09-22 18:48     ` Tamas K Lengyel
2014-09-23 12:18       ` Ian Campbell
2014-10-01 17:32         ` Aravindh Puthiyaparambil (aravindp)

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=1411066476.1920.25.camel@citrix.com \
    --to=ian.campbell@citrix.com \
    --cc=andres@lagarcavilla.org \
    --cc=dgdegra@tycho.nsa.gov \
    --cc=ian.jackson@eu.citrix.com \
    --cc=jbeulich@suse.com \
    --cc=julien.grall@linaro.org \
    --cc=stefano.stabellini@citrix.com \
    --cc=tim@xen.org \
    --cc=tklengyel@sec.in.tum.de \
    --cc=xen-devel@lists.xen.org \
    /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).