All of lore.kernel.org
 help / color / mirror / Atom feed
From: Julien Grall <julien.grall@linaro.org>
To: Ian Campbell <ian.campbell@citrix.com>
Cc: stefano.stabellini@eu.citrix.com, tim@xen.org,
	Fu Wei <fu.wei@linaro.org>,
	xen-devel@lists.xen.org
Subject: Re: [PATCH] xen: arm: setup sane EL1 state while building domain 0.
Date: Mon, 17 Mar 2014 15:37:20 +0000	[thread overview]
Message-ID: <532716B0.6030508@linaro.org> (raw)
In-Reply-To: <1395070269-32356-1-git-send-email-ian.campbell@citrix.com>

Hi Ian,

On 03/17/2014 03:31 PM, Ian Campbell wrote:
> The address translation functions used while building dom0 rely on certain EL1
> state being configured. In particular they are subject to the behaviour of
> SCTLR_EL1.M (stage 1 MMU enabled).
> 
> The Xen (and Linux) boot protocol require that the kernel be entered with the
> MMU disabled but they don't say anything explicitly about exception levels
> other than the one which is active when entering the kernels. Arguably the
> protocol could be said to apply to all exception levels but in any case we
> should cope with this and setup the EL1 state as necessary.
> 
> Fu Wei discovered this when booting Xen from grub.efi over UEFI, it's not
> clear whether grub or UEFI is responsible for leaving stage 1 MMU enabled.

I was about to send a similar patch :).

>      /* The following loads use the domain's p2m */
>      p2m_load_VTTBR(d);
> +    /* Various EL2 operations, such as guest address translations used
> +     * part of the domain build, rely on EL1 state (i.e. whether the
> +     * guest has paging enabled). Since the bootloader may have left
> +     * this state in an arbitrary configuration set it to something
> +     * safe here.
> +     */
> +    WRITE_SYSREG32(SCTLR_GUEST_INIT, SCTLR_EL1);

I think it would make more sense to create a new function call
p2m_restore_state which contains:

void p2m_restore_state(struct vcpu *n)
{
    register_t hcr;

    hcr = READ_SYSREG(HCR_EL2);
    WRITE_SYSREG(hcr & ~HCR_VM, HCR_EL2);
    isb();

    p2m_load_VTTBR(n->domain);
    isb();

    if ( is_pv32_domain(n->domain) )
        hcr &= ~HCR_RW;
    else
        hcr |= HCR_RW;

    WRITE_SYSREG(n->arch.sctlr, SCTLR_EL1);
    isb();

    WRITE_SYSREG(hcr, HCR_EL2);
    isb();
}

IHMO, it's more clear than continuing "hardcoding" setup in dom0 code.

Regards,

-- 
Julien Grall

  reply	other threads:[~2014-03-17 15:37 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-17 15:31 [PATCH] xen: arm: setup sane EL1 state while building domain 0 Ian Campbell
2014-03-17 15:37 ` Julien Grall [this message]
2014-03-17 15:46   ` Ian Campbell
2014-03-17 15:50     ` Julien Grall
2014-03-18  3:22 ` Fu Wei
2014-03-18  9:41   ` Ian Campbell
2014-03-18 12:16     ` Julien Grall
2014-03-18 12:37     ` Fu Wei

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=532716B0.6030508@linaro.org \
    --to=julien.grall@linaro.org \
    --cc=fu.wei@linaro.org \
    --cc=ian.campbell@citrix.com \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=tim@xen.org \
    --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 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.