All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Jan Beulich" <JBeulich@suse.com>
To: Tamas K Lengyel <tamas.lengyel@zentific.com>
Cc: Tim Deegan <tim@xen.org>, Kevin Tian <kevin.tian@intel.com>,
	wei.liu2@citrix.com, Ian Campbell <ian.campbell@citrix.com>,
	Razvan Cojocaru <rcojocaru@bitdefender.com>,
	Stefano Stabellini <stefano.stabellini@eu.citrix.com>,
	Eddie Dong <eddie.dong@intel.com>,
	Ian Jackson <ian.jackson@eu.citrix.com>,
	"xen-devel@lists.xen.org" <xen-devel@lists.xen.org>,
	Andres Lagar-Cavilla <andres@lagarcavilla.org>,
	Jun Nakajima <jun.nakajima@intel.com>,
	rshriram@cs.ubc.ca, Keir Fraser <keir@xen.org>,
	Daniel De Graaf <dgdegra@tycho.nsa.gov>,
	yanghy@cn.fujitsu.com
Subject: Re: [RFC PATCH V2 1/8] xen/mem_event: Cleanup of mem_event structures
Date: Thu, 22 Jan 2015 16:34:54 +0000	[thread overview]
Message-ID: <54C134BE0200007800058619@mail.emea.novell.com> (raw)
In-Reply-To: <CAErYnsggnhuUSfPxmBjNxd0gu_xwAimDcJAEgE9FDaLF1o7GrQ@mail.gmail.com>

>>> On 22.01.15 at 17:23, <tamas.lengyel@zentific.com> wrote:
> On Thu, Jan 22, 2015 at 5:00 PM, Jan Beulich <JBeulich@suse.com> wrote:
>>>>> On 22.01.15 at 16:34, <tamas.lengyel@zentific.com> wrote:
>>> On Thu, Jan 22, 2015 at 4:00 PM, Jan Beulich <JBeulich@suse.com> wrote:
>>>>>>> On 18.01.15 at 16:17, <tamas.lengyel@zentific.com> wrote:
>>>>> --- a/xen/include/public/mem_event.h
>>>>> +++ b/xen/include/public/mem_event.h
>>>>> @@ -27,9 +27,15 @@
>>>>>  #ifndef _XEN_PUBLIC_MEM_EVENT_H
>>>>>  #define _XEN_PUBLIC_MEM_EVENT_H
>>>>>
>>>>> +#if !defined(__XEN__) && !defined(__XEN_TOOLS__)
>>>>> +#error "vm event operations are intended for use only by Xen or node
>>>>> control tools"
>>>>> +#endif
>>>>> +
>>>>>  #include "xen.h"
>>>>>  #include "io/ring.h"
>>>>>
>>>>> +#define MEM_EVENT_INTERFACE_VERSION 0x00000001
>>>>
>>>> This doesn't appear to be used anywhere, and hence isn't useful to
>>>> add here.
>>>
>>> It is intended to be used to establish an API version for backwards
>>> compatibility. We don't have any backwards compatibility checks at
>>> this point, but this will change as soon as we extend this interface
>>> as things go forward in the future.
>>
>> But without the caller passing you the version of the ABI it uses,
>> how do you want to do such compatibility handling?
> 
> True. I was more imagining this flag to be used by the user to
> determine (and know) what Xen supports. Currently we have to deduce
> that by checking for various functions and structures being defined.
> This would just simply that process for the user.

If you think this will work going forward... Domctl and sysctl
specifically do it the other way. Plus if you do it the way you
describe, I can't see why __XEN_LATEST_INTERFACE_VERSION__
wouldn't be sufficient.

>>>>> +struct mem_event_mem_access_data {
>>>>>      uint64_t gfn;
>>>>>      uint64_t offset;
>>>>>      uint64_t gla; /* if gla_valid */
>>>>> -
>>>>> -    uint32_t p2mt;
>>>>> -
>>>>>      uint16_t access_r:1;
>>>>>      uint16_t access_w:1;
>>>>>      uint16_t access_x:1;
>>>>
>>>> I also wonder how well thought through the use of bit fields here is.
>>>
>>> It saves some space on the ring. Maybe a uint8_t is enough.
>>
>> The same can be achieved with a flags field and a set of constants.
> 
> True. I prefer having the variables directly describing its values
> instead of having separate defines for the bits (like how i did for
> struct npfec). IMHO it easier to read, but that's of course just a
> personal preference.

I too prefer this, but interface definitions require putting aside
such preferences. Just consider what happens on bi-endianness
architectures when consumer and producer use different
endianness. Since the bitfields aren't accessible as an addressable
entity, you can't byte swap them as you would need to. Plus
compilers have (or should I say take) quite a bit more freedom on
what they do to bitfields than what they may do to ordinary
structure members.

>>> Also, how
>>>> architecture-neutral is int3 really?!
>>>
>>> These aren't architecture neutral by any means. However, we likely are
>>> going to have SMC events on the ARM as well, which won't be
>>> architecture neutral either. I don't see a way around it. But why
>>> would this interface have to be architecture neutral? IMHO a comment
>>> saying these are features only for Intel/AMD/ARM would be sufficient.
>>> We already do checks for the architecture when the user attempts to
>>> enable these features to see if it actually supported on the hardware
>>> or not.
>>
>> For the one at hand - why can't it be named software_breakpoint
>> or some such?
> 
> It can be named that - what would be the benefit? We still don't have
> software breakpoints trappable to hyp mode on ARM so it still will be
> just for x86.

But you could re-use "software_breakpoint" for ARM, while you can't
re-use "int3".

>>>>> +typedef struct mem_event_st {
>>>>> +    uint32_t flags;
>>>>> +    uint32_t vcpu_id;
>>>>> +    uint32_t reason;
>>>>> +
>>>>> +    union {
>>>>> +        struct mem_event_paging_data     mem_paging_event;
>>>>> +        struct mem_event_sharing_data    mem_sharing_event;
>>>>> +        struct mem_event_mem_access_data mem_access_event;
>>>>> +        struct mem_event_cr_data         cr_event;
>>>>> +        struct mem_event_int3_data       int3_event;
>>>>> +        struct mem_event_singlestep_data singlestep_event;
>>>>> +        struct mem_event_msr_data        msr_event;
>>>>> +    };
>>>>>
>>>>> -    uint16_t reason;
>>>>> -    struct mem_event_regs_x86 x86_regs;
>>>>> +    struct mem_event_regs regs;
>>>>>  } mem_event_request_t, mem_event_response_t;
>>>>
>>>> This structure's layout now differs between 32- and 64-bit, which I'm
>>>> sure you want to avoid.
>>>
>>> Any suggestions? Make the struct(s) packed?
>>
>> No, add explicit padding.
> 
> I was hoping to avoid that as it makes the structure quite messy to
> read and in case a new struct is introduced to be delivered via
> vm_event it may has to adjust the padding again.

How that? Fields with alignment bigger than that of uint64_t aren't
likely to appear.

> Wouldn't making the
> struct packed just take care of it automatically?

How would you envision to do that without using compiler
extensions?

Jan

  reply	other threads:[~2015-01-22 16:34 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-18 15:17 [RFC PATCH V2 0/8] xen: Clean-up of mem_event subsystem Tamas K Lengyel
2015-01-18 15:17 ` [RFC PATCH V2 1/8] xen/mem_event: Cleanup of mem_event structures Tamas K Lengyel
2015-01-22 12:43   ` Tim Deegan
2015-01-22 12:50     ` Razvan Cojocaru
2015-01-22 12:50     ` Tamas K Lengyel
2015-01-22 12:53       ` Razvan Cojocaru
2015-01-22 13:11       ` Tim Deegan
2015-01-22 15:00   ` Jan Beulich
2015-01-22 15:34     ` Tamas K Lengyel
2015-01-22 16:00       ` Jan Beulich
2015-01-22 16:23         ` Tamas K Lengyel
2015-01-22 16:34           ` Jan Beulich [this message]
     [not found]             ` <CAErYnsj8B1Fbo=JD3hLz-8kjtt-FoWTrSkGnbkvVf=iR64MDBQ@mail.gmail.com>
2015-01-23  9:00               ` Jan Beulich
2015-01-23  9:18                 ` Tamas K Lengyel
2015-01-29 11:54       ` Tamas K Lengyel
2015-01-29 12:02         ` Jan Beulich
2015-01-29 12:09           ` Tamas K Lengyel
2015-01-29 12:15             ` Tamas K Lengyel
2015-01-29 12:51             ` Jan Beulich
2015-01-29 13:03               ` Tamas K Lengyel
2015-01-18 15:17 ` [RFC PATCH V2 2/8] xen/mem_event: Rename the mem_event ring from 'access' to 'monitor' Tamas K Lengyel
2015-01-22 12:53   ` Tim Deegan
2015-01-22 14:12     ` Tamas K Lengyel
2015-01-22 15:02   ` Jan Beulich
2015-01-22 15:42     ` Tamas K Lengyel
2015-01-18 15:17 ` [RFC PATCH V2 3/8] xen/mem_paging: Convert mem_event_op to mem_paging_op Tamas K Lengyel
2015-01-22 13:03   ` Tim Deegan
2015-01-22 15:09   ` Jan Beulich
2015-01-22 15:41     ` Tamas K Lengyel
2015-01-18 15:17 ` [RFC PATCH V2 4/8] x86/hvm: rename hvm_memory_event_* functions to hvm_event_* Tamas K Lengyel
2015-01-22 13:05   ` Tim Deegan
2015-01-22 15:56   ` Andrew Cooper
2015-01-22 16:34     ` Tamas K Lengyel
2015-01-18 15:17 ` [RFC PATCH V2 5/8] xen/mem_event: Rename mem_event to vm_event Tamas K Lengyel
2015-01-22 14:52   ` Tim Deegan
2015-01-22 15:02     ` Tamas K Lengyel
2015-01-18 15:17 ` [RFC PATCH V2 6/8] xen/vm_event: Decouple vm_event and mem_access Tamas K Lengyel
2015-01-22 14:56   ` Tim Deegan
2015-01-22 15:35     ` Tamas K Lengyel
2015-01-18 15:18 ` [RFC PATCH V2 7/8] tools/tests: Clean-up tools/tests/xen-access Tamas K Lengyel
2015-01-18 15:18 ` [RFC PATCH V2 8/8] x86/hvm: factor out vm_event related functions into separate file Tamas K Lengyel
2015-01-22 15:00   ` Tim Deegan
2015-01-22 15:36     ` Tamas K Lengyel
2015-01-22 16:25   ` Jan Beulich
2015-01-22 16:42     ` Tamas K Lengyel
2015-01-22 16:50       ` Tim Deegan
2015-01-23  8:56       ` Razvan Cojocaru
2015-01-23  9:03         ` Jan Beulich
2015-01-23  9:21           ` Tamas K Lengyel
2015-01-22 16:32   ` Andrew Cooper
2015-01-22 16:41     ` Tamas K Lengyel
2015-01-19 13:03 ` [RFC PATCH V2 0/8] xen: Clean-up of mem_event subsystem Andrew Cooper
2015-01-21 10:59   ` Tamas K Lengyel

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=54C134BE0200007800058619@mail.emea.novell.com \
    --to=jbeulich@suse.com \
    --cc=andres@lagarcavilla.org \
    --cc=dgdegra@tycho.nsa.gov \
    --cc=eddie.dong@intel.com \
    --cc=ian.campbell@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=jun.nakajima@intel.com \
    --cc=keir@xen.org \
    --cc=kevin.tian@intel.com \
    --cc=rcojocaru@bitdefender.com \
    --cc=rshriram@cs.ubc.ca \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=tamas.lengyel@zentific.com \
    --cc=tim@xen.org \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xen.org \
    --cc=yanghy@cn.fujitsu.com \
    /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.