xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: James Morse <james.morse@arm.com>
To: Florian Jakobsmeier <florian.jakobsmeier@googlemail.com>,
	Julien Grall <julien.grall@arm.com>
Cc: xen-devel <xen-devel@lists.xenproject.org>,
	Stefano Stabellini <sstabellini@kernel.org>
Subject: Re: xen/arm: Software Step ARMv8 - PC stuck on instruction
Date: Thu, 03 Aug 2017 11:46:17 +0100	[thread overview]
Message-ID: <5982FEF9.7080007@arm.com> (raw)
In-Reply-To: <CAAH2inecSROApnj=bevD7mxPFR-K-ctzVFg2EEE6X+BEvzSjEg@mail.gmail.com>

Hi Florian,

On 03/08/17 11:16, Florian Jakobsmeier wrote:
> This is the current version:

I'm not familiar with Xen, so forgive my annotations:

> asmlinkage void leave_hypervisor_tail(void)
>>  {
>> +    /*This methode will be called after the 'guest_entry' macro in
>> /arch/arm64/entry.S set guest registers
>> +    Check single_step_enabled flag in domain struct here and set needed
>> registers
>> +    */
>> +
>> +    struct vcpu *v = current;
>> +
>> +    if ( unlikely(v->domain->arch.monitor.singlestep_enabled ) )
>> +    {
>> +        if(!(guest_cpu_user_regs()->cpsr & 0b1000))

This tests SPSR.M[4], which is set for exits from AARCH32.


>> +        {
>> +            WRITE_SYSREG(READ_SYSREG(MDSCR_EL1) | 0x1, MDSCR_EL1);

Sets MDSCR.EL1.SS to enable the state machine.


>> +            WRITE_SYSREG(READ_SYSREG(MDCR_EL2)  | HDCR_TDE, MDCR_EL2);

Sets TDE to trap debug exceptions to EL2 from lower exception levels. I'm
surprised this isn't always set for Xen. Do you allow guests to use the debug
features for their own purposes?


>> +            guest_cpu_user_regs()->cpsr = guest_cpu_user_regs()->cpsr |
>> 0x200000;

Sets SPSR.SS to suppress the step exception in the guest until its executed an
instruction.


>> +            WRITE_SYSREG( READ_SYSREG(DAIF) & ~0x200, DAIF);

Here I'm confused. This looks like you are clearing PSTATE.D from the DAIF
register for EL2. This means debug exceptions are unmasked for exceptions from
Xen at EL2.

If you ERET with PSTATE.D clear the SPSR.SS bit will be discarded instead. I
thin this is your bug. The rules in 'D2.12.4 Entering the active-not-pending
state' require 'Debug exceptions are disabled from the current Exception level'.

You've set MDSCR_EL1.SS, if you also have MDSCR_EL1.KDE set you will start
single-stepping Xen once the register writes take effect, (which may be before
or after this:)

>> +            isb();

What are you synchronising here? (Unless you want to single-step Xen I suspect
you don't need this at all.)



Do you still see the issue if you remove the PSTATE.D write?


Thanks,

James


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  reply	other threads:[~2017-08-03 10:47 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-04 12:30 xen/arm: Software Step ARMv8 - PC stuck on instruction Florian Jakobsmeier
2017-07-04 18:37 ` Julien Grall
2017-07-05 14:03   ` Florian Jakobsmeier
2017-07-26 13:12     ` Florian Jakobsmeier
2017-08-02 13:32       ` Julien Grall
2017-08-03  9:49         ` James Morse
2017-08-03 10:16         ` Florian Jakobsmeier
2017-08-03 10:46           ` James Morse [this message]
2017-08-03 11:08             ` Julien Grall
2017-08-03 12:29               ` Florian Jakobsmeier
2017-08-03 13:02                 ` James Morse
2017-08-03 16:00                   ` Florian Jakobsmeier
2017-08-07 17:05                     ` James Morse

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=5982FEF9.7080007@arm.com \
    --to=james.morse@arm.com \
    --cc=florian.jakobsmeier@googlemail.com \
    --cc=julien.grall@arm.com \
    --cc=sstabellini@kernel.org \
    --cc=xen-devel@lists.xenproject.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).