xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Jan Beulich <JBeulich@suse.com>,
	xen-devel <xen-devel@lists.xenproject.org>
Cc: Keir Fraser <keir@xen.org>
Subject: Re: [PATCH 3/4] x86: move I/O emulation stubs off the stack
Date: Tue, 19 May 2015 18:48:53 +0100	[thread overview]
Message-ID: <555B7785.9050106@citrix.com> (raw)
In-Reply-To: <5559FB6E020000780007B19E@mail.emea.novell.com>

On 18/05/15 13:47, Jan Beulich wrote:
> This is needed as stacks are going to become non-executable.
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>
>
> --- a/xen/arch/x86/traps.c
> +++ b/xen/arch/x86/traps.c
> @@ -2006,7 +2006,7 @@ static int emulate_privileged_op(struct 
>                             ? (*(u32 *)&regs->reg = (val)) \
>                             : (*(u16 *)&regs->reg = (val)))
>      unsigned long code_base, code_limit;
> -    char io_emul_stub[32];
> +    char *io_emul_stub = NULL;
>      void (*io_emul)(struct cpu_user_regs *) __attribute__((__regparm__(1)));
>      uint64_t val;
>  
> @@ -2195,6 +2195,9 @@ static int emulate_privileged_op(struct 
>       * GPR context. This is needed for some systems which (ab)use IN/OUT
>       * to communicate with BIOS code in system-management mode.
>       */

The comment (just out of context) needs tweaking.

> +    io_emul_stub = map_domain_page(this_cpu(stubs.mfn)) +
> +                   (this_cpu(stubs.addr) & (PAGE_SIZE - 1)) +
> +                   STUB_BUF_SIZE / 2;
>      /* movq $host_to_guest_gpr_switch,%rcx */
>      io_emul_stub[0] = 0x48;
>      io_emul_stub[1] = 0xb9;
> @@ -2212,7 +2215,7 @@ static int emulate_privileged_op(struct 
>      io_emul_stub[15] = 0xc3;
>  
>      /* Handy function-typed pointer to the stub. */
> -    io_emul = (void *)io_emul_stub;
> +    io_emul = (void *)(this_cpu(stubs.addr) + STUB_BUF_SIZE / 2);

As an unrelated observation during review, the two gpr switch functions
should probably gain some knowledge of TRAP_regs_partial

~Andrew

>  
>      if ( ioemul_handle_quirk )
>          ioemul_handle_quirk(opcode, &io_emul_stub[12], regs);
> @@ -2777,9 +2780,13 @@ static int emulate_privileged_op(struct 
>   done:
>      instruction_done(regs, eip, bpmatch);
>   skip:
> +    if ( io_emul_stub )
> +        unmap_domain_page(io_emul_stub);
>      return EXCRET_fault_fixed;
>  
>   fail:
> +    if ( io_emul_stub )
> +        unmap_domain_page(io_emul_stub);
>      return 0;
>  }
>  
>
>
>

  reply	other threads:[~2015-05-19 17:53 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-18 10:28 [PATCH 0/4] x86: don't default to executable mappings Jan Beulich
2015-05-18 12:46 ` [PATCH 1/4] x86: move syscall trampolines off the stack Jan Beulich
2015-05-18 18:39   ` Andrew Cooper
2015-05-19  6:41     ` Jan Beulich
2015-05-19  9:24       ` Andrew Cooper
2015-05-19 16:59   ` Andrew Cooper
2015-05-20  9:16     ` Jan Beulich
2015-05-20 13:37     ` Jan Beulich
2015-05-20 13:58       ` Andrew Cooper
2015-05-20 15:54     ` Jan Beulich
2015-05-18 12:46 ` [PATCH 2/4] x86emul: move stubs " Jan Beulich
2015-05-19 17:33   ` Andrew Cooper
2015-05-20  9:25     ` Jan Beulich
2015-05-18 12:47 ` [PATCH 3/4] x86: move I/O emulation " Jan Beulich
2015-05-19 17:48   ` Andrew Cooper [this message]
2015-05-20 13:57     ` Jan Beulich
2015-05-18 12:47 ` [PATCH 4/4] x86: switch default mapping attributes to non-executable Jan Beulich
2015-05-19 18:53   ` Andrew Cooper
2015-05-20  9:32     ` Jan Beulich

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=555B7785.9050106@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=keir@xen.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).