All of lore.kernel.org
 help / color / mirror / Atom feed
From: Avi Kivity <avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
To: "Zhang, Xiantao" <xiantao.zhang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Cc: kvm-devel
	<kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>,
	kvm-ppc-devel
	<kvm-ppc-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org>,
	jyoung5-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org
Subject: Re: [Disscussion] Moving x86 code out of kvm.h
Date: Thu, 15 Nov 2007 16:21:02 +0200	[thread overview]
Message-ID: <473C55CE.9010000@qumranet.com> (raw)
In-Reply-To: <42DFA526FC41B1429CE7279EF83C6BDC9A044F-wq7ZOvIWXbMAbVU2wMM1CrfspsVTdybXVpNB7YpNyf8@public.gmane.org>

Zhang, Xiantao wrote:
>>> For driver/kvm/kvm.h,  I have a proposal before in mailing list.  In
>>> my proposal, we can split x86-specific code of kvm.h into current
>>> x86.h, and make code in kvm.h as common. Then, we rename kvm.h to
>>> kvm_comm.h, and also rename x86.h to kvm-x86.h, and meantime
>>> kvm-x86.h would include kvm_comm.h. At compile time, we can make
>>> symbol link for changing kvm-x86.h to kvm.h.  So, it should be more
>>> portable, because different archs can define its kvm-$arch.h to hold
>>> its arch-specific code. 
>>>
>>>       
>> I prefer not to have dynamic symlinks, it's too tricky.
>>
>> What's wrong with just the first part, x86.h which includes kvm.h?
>> x86.c will include x86.h, and arch neutral files will include kvm.h.
>>     
>
> I think it may have issues. For example, where do we put struct
> kvm_vcpu, and struct kvm? If we place them in x86.h, then kvm_main.c and
> other neutral files can't reach it.  If we put them in kvm.h, how to
> handle arch-specific fields in them ?
>   

Someone (I forget who) suggested using the same trick we use for vmx and 
svm.  We nest as follows:

struct vcpu_vmx {
   struct vcpu_x86 {
        struct kvm_vcpu {
             // common fields;
        } vcpu;
        // x86 specific fields;
   } x86;
   // vmx specific fields;
};

Allocation is done by arch specific code which allocates the outermost 
structure.  Common code sees only kvm_vcpu and its fields.  When it 
calls x86 arch hooks, they use the vcpu_x86() macro (which is a call to 
container_of()) to gain access to x86 specific fields.  When x86 code 
calls vmx specific code (using kvm_x86_ops), that uses vcpu_vmx() to 
gain access to the vmx specific fields.  Any similarity to a language 
derived from C, living or dead, is purely coincidental and unintended.

-- 
error compiling committee.c: too many arguments to function


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/

  parent reply	other threads:[~2007-11-15 14:21 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-15  8:24 [Disscussion] Moving x86 code out of kvm.h Jerone Young
2007-11-15  8:34 ` Avi Kivity
     [not found]   ` <473C0494.2080404-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-11-15  8:30     ` Izik Eidus
     [not found]       ` <1195115455.3165.6.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2007-11-15  8:42         ` Avi Kivity
2007-11-15 16:44     ` Jerone Young
2007-11-15 10:30 ` Zhang, Xiantao
     [not found]   ` <42DFA526FC41B1429CE7279EF83C6BDC9A042D-wq7ZOvIWXbMAbVU2wMM1CrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2007-11-15 10:52     ` Avi Kivity
     [not found]       ` <473C2509.5030308-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-11-15 14:02         ` Zhang, Xiantao
     [not found]           ` <42DFA526FC41B1429CE7279EF83C6BDC9A044F-wq7ZOvIWXbMAbVU2wMM1CrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2007-11-15 14:21             ` Avi Kivity [this message]
     [not found]               ` <473C55CE.9010000-atKUWr5tajBWk0Htik3J/w@public.gmane.org>
2007-11-15 14:30                 ` Zhang, Xiantao

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=473C55CE.9010000@qumranet.com \
    --to=avi-atkuwr5tajbwk0htik3j/w@public.gmane.org \
    --cc=jyoung5-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org \
    --cc=kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    --cc=kvm-ppc-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    --cc=xiantao.zhang-ral2JQCrhuEAvxtiuMwx3w@public.gmane.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.