From: "Jan Beulich" <JBeulich@suse.com>
To: Ed White <edmund.h.white@intel.com>
Cc: Tim Deegan <tim@xen.org>, Ravi Sahita <ravi.sahita@intel.com>,
Wei Liu <wei.liu2@citrix.com>,
George Dunlap <george.dunlap@eu.citrix.com>,
Andrew Cooper <andrew.cooper3@citrix.com>,
Ian Jackson <ian.jackson@eu.citrix.com>,
xen-devel@lists.xen.org, tlengyel@novetta.com,
Daniel De Graaf <dgdegra@tycho.nsa.gov>
Subject: Re: [PATCH v4 11/15] x86/altp2m: define and implement alternate p2m HVMOP types.
Date: Fri, 10 Jul 2015 11:01:01 +0100 [thread overview]
Message-ID: <559FB3FD020000780008F5E3@mail.emea.novell.com> (raw)
In-Reply-To: <1436489553-6300-12-git-send-email-edmund.h.white@intel.com>
>>> On 10.07.15 at 02:52, <edmund.h.white@intel.com> wrote:
> --- a/xen/arch/x86/hvm/hvm.c
> +++ b/xen/arch/x86/hvm/hvm.c
> @@ -6443,6 +6443,144 @@ long do_hvm_op(unsigned long op, XEN_GUEST_HANDLE_PARAM(void) arg)
> break;
> }
>
> + case HVMOP_altp2m:
> + {
> + struct xen_hvm_altp2m_op a;
> + struct domain *d = NULL;
> +
> + if ( copy_from_guest(&a, arg, 1) )
> + return -EFAULT;
> +
> + switch ( a.cmd )
> + {
> + case HVMOP_altp2m_get_domain_state:
> + case HVMOP_altp2m_set_domain_state:
> + case HVMOP_altp2m_create_p2m:
> + case HVMOP_altp2m_destroy_p2m:
> + case HVMOP_altp2m_switch_p2m:
> + case HVMOP_altp2m_set_mem_access:
> + case HVMOP_altp2m_change_gfn:
> + d = rcu_lock_domain_by_any_id(a.domain);
> + if ( d == NULL )
> + return -ESRCH;
> +
> + if ( !is_hvm_domain(d) || !hvm_altp2m_supported() )
> + rc = -EINVAL;
> +
> + break;
> + case HVMOP_altp2m_vcpu_enable_notify:
> +
> + break;
The blank line ought to go ahead of the case label.
> + default:
> + return -ENOSYS;
> +
> + break;
Bogus (unreachable) break.
> + }
> +
> + if ( !rc )
> + {
> + switch ( a.cmd )
> + {
> + case HVMOP_altp2m_get_domain_state:
> + a.u.domain_state.state = altp2m_active(d);
> + rc = __copy_to_guest(arg, &a, 1) ? -EFAULT : 0;
> +
> + break;
> + case HVMOP_altp2m_set_domain_state:
> + {
> + struct vcpu *v;
> + bool_t ostate;
> +
> + if ( nestedhvm_enabled(d) )
> + {
> + rc = -EINVAL;
> + break;
> + }
> +
> + ostate = d->arch.altp2m_active;
> + d->arch.altp2m_active = !!a.u.domain_state.state;
> +
> + /* If the alternate p2m state has changed, handle appropriately */
> + if ( d->arch.altp2m_active != ostate &&
> + (ostate || !(rc = p2m_init_altp2m_by_id(d, 0))) )
> + {
> + for_each_vcpu( d, v )
> + {
> + if ( !ostate )
> + altp2m_vcpu_initialise(v);
> + else
> + altp2m_vcpu_destroy(v);
> + }
> +
> + if ( ostate )
> + p2m_flush_altp2m(d);
> + }
> +
> + break;
> + }
> + default:
> + {
Pointless brace.
> + if ( !(d ? d : current->domain)->arch.altp2m_active )
This is bogus: d is NULL if and only if altp2m_vcpu_enable_notify,
i.e. I don't see why you can't just use current->domain inside that
case (and you really do). That would then also eliminate the need
for this redundant and obfuscating switch() nesting you use.
> +
> +struct xen_hvm_altp2m_set_mem_access {
> + /* view */
> + uint16_t view;
> + /* Memory type */
> + uint16_t hvmmem_access; /* xenmem_access_t */
> + uint8_t pad[4];
> + /* gfn */
> + uint64_t gfn;
> +};
> +typedef struct xen_hvm_altp2m_set_mem_access
> xen_hvm_altp2m_set_mem_access_t;
> +DEFINE_XEN_GUEST_HANDLE(xen_hvm_altp2m_set_mem_access_t);
> +
> +struct xen_hvm_altp2m_change_gfn {
> + /* view */
> + uint16_t view;
> + uint8_t pad[6];
> + /* old gfn */
> + uint64_t old_gfn;
> + /* new gfn, INVALID_GFN (~0UL) means revert */
> + uint64_t new_gfn;
> +};
> +typedef struct xen_hvm_altp2m_change_gfn xen_hvm_altp2m_change_gfn_t;
> +DEFINE_XEN_GUEST_HANDLE(xen_hvm_altp2m_change_gfn_t);
> +
> +struct xen_hvm_altp2m_op {
> + uint32_t cmd;
> +/* Get/set the altp2m state for a domain */
> +#define HVMOP_altp2m_get_domain_state 1
> +#define HVMOP_altp2m_set_domain_state 2
> +/* Set the current VCPU to receive altp2m event notifications */
> +#define HVMOP_altp2m_vcpu_enable_notify 3
> +/* Create a new view */
> +#define HVMOP_altp2m_create_p2m 4
> +/* Destroy a view */
> +#define HVMOP_altp2m_destroy_p2m 5
> +/* Switch view for an entire domain */
> +#define HVMOP_altp2m_switch_p2m 6
> +/* Notify that a page of memory is to have specific access types */
> +#define HVMOP_altp2m_set_mem_access 7
> +/* Change a p2m entry to have a different gfn->mfn mapping */
> +#define HVMOP_altp2m_change_gfn 8
> + domid_t domain;
> + uint8_t pad[2];
While you added padding fields as asked for, you still don't verify
them to be zero on input.
Afaict all other questions raised on v3 still stand.
Jan
next prev parent reply other threads:[~2015-07-10 10:01 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-10 0:52 [PATCH v4 00/15] Alternate p2m: support multiple copies of host p2m Ed White
2015-07-10 0:52 ` [PATCH v4 01/15] common/domain: Helpers to pause a domain while in context Ed White
2015-07-10 0:52 ` [PATCH v4 02/15] VMX: VMFUNC and #VE definitions and detection Ed White
2015-07-10 0:52 ` [PATCH v4 03/15] VMX: implement suppress #VE Ed White
2015-07-10 9:09 ` Jan Beulich
2015-07-10 19:22 ` Sahita, Ravi
2015-07-10 0:52 ` [PATCH v4 04/15] x86/HVM: Hardware alternate p2m support detection Ed White
2015-07-10 0:52 ` [PATCH v4 05/15] x86/altp2m: basic data structures and support routines Ed White
2015-07-10 9:13 ` Jan Beulich
2015-07-10 0:52 ` [PATCH v4 06/15] VMX/altp2m: add code to support EPTP switching and #VE Ed White
2015-07-10 16:48 ` George Dunlap
2015-07-10 0:52 ` [PATCH v4 07/15] VMX: add VMFUNC leaf 0 (EPTP switching) to emulator Ed White
2015-07-10 9:30 ` Jan Beulich
2015-07-11 20:01 ` Sahita, Ravi
2015-07-11 21:25 ` Sahita, Ravi
2015-07-13 7:18 ` Jan Beulich
2015-07-13 7:13 ` Jan Beulich
2015-07-10 0:52 ` [PATCH v4 08/15] x86/altp2m: add control of suppress_ve Ed White
2015-07-10 9:39 ` Jan Beulich
2015-07-10 11:11 ` George Dunlap
2015-07-10 11:49 ` Jan Beulich
2015-07-10 11:56 ` George Dunlap
2015-07-10 17:02 ` George Dunlap
2015-07-11 21:29 ` Sahita, Ravi
2015-07-10 0:52 ` [PATCH v4 09/15] x86/altp2m: alternate p2m memory events Ed White
2015-07-10 1:01 ` Lengyel, Tamas
2015-07-10 0:52 ` [PATCH v4 10/15] x86/altp2m: add remaining support routines Ed White
2015-07-10 9:41 ` Jan Beulich
2015-07-10 17:15 ` George Dunlap
2015-07-11 20:20 ` Sahita, Ravi
2015-07-10 0:52 ` [PATCH v4 11/15] x86/altp2m: define and implement alternate p2m HVMOP types Ed White
2015-07-10 10:01 ` Jan Beulich [this message]
2015-07-10 22:03 ` Sahita, Ravi
2015-07-13 7:25 ` Jan Beulich
2015-07-13 23:39 ` Sahita, Ravi
2015-07-14 8:58 ` Jan Beulich
2015-07-10 0:52 ` [PATCH v4 12/15] x86/altp2m: Add altp2mhvm HVM domain parameter Ed White
2015-07-10 8:53 ` Wei Liu
2015-07-10 17:32 ` George Dunlap
2015-07-10 22:12 ` Sahita, Ravi
2015-07-14 11:50 ` George Dunlap
2015-07-10 0:52 ` [PATCH v4 13/15] x86/altp2m: XSM hooks for altp2m HVM ops Ed White
2015-07-10 0:52 ` [PATCH v4 14/15] tools/libxc: add support to altp2m hvmops Ed White
2015-07-10 8:46 ` Ian Campbell
2015-07-10 0:52 ` [PATCH v4 15/15] tools/xen-access: altp2m testcases Ed White
2015-07-10 1:35 ` Lengyel, Tamas
2015-07-11 6:06 ` Razvan Cojocaru
2015-07-10 8:50 ` Ian Campbell
2015-07-10 8:55 ` Wei Liu
2015-07-10 9:12 ` Wei Liu
2015-07-10 9:20 ` Ian Campbell
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=559FB3FD020000780008F5E3@mail.emea.novell.com \
--to=jbeulich@suse.com \
--cc=andrew.cooper3@citrix.com \
--cc=dgdegra@tycho.nsa.gov \
--cc=edmund.h.white@intel.com \
--cc=george.dunlap@eu.citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=ravi.sahita@intel.com \
--cc=tim@xen.org \
--cc=tlengyel@novetta.com \
--cc=wei.liu2@citrix.com \
--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).