mirror of
https://github.com/xen-project/xen.git
synced 2026-10-29 18:50:05 +01:00
merge?
This commit is contained in:
commit
288f60bb0b
14 files changed
+211
-79
No files matched your search
@@ -690,6 +690,8 @@ static PyObject *pyxc_physinfo(PyObject *self,
|
||||
{
|
||||
XcObject *xc = (XcObject *)self;
|
||||
xc_physinfo_t info;
|
||||
char cpu_cap[128], *p=cpu_cap, *q=cpu_cap;
|
||||
int i;
|
||||
|
||||
if ( !PyArg_ParseTuple(args, "") )
|
||||
return NULL;
|
||||
@@ -697,14 +699,25 @@ static PyObject *pyxc_physinfo(PyObject *self,
|
||||
if ( xc_physinfo(xc->xc_handle, &info) != 0 )
|
||||
return PyErr_SetFromErrno(xc_error);
|
||||
|
||||
return Py_BuildValue("{s:i,s:i,s:i,s:i,s:l,s:l,s:i}",
|
||||
*q=0;
|
||||
for(i=0;i<sizeof(info.hw_cap)/4;i++)
|
||||
{
|
||||
p+=sprintf(p,"%08x:",info.hw_cap[i]);
|
||||
if(info.hw_cap[i])
|
||||
q=p;
|
||||
}
|
||||
if(q>cpu_cap)
|
||||
*(q-1)=0;
|
||||
|
||||
return Py_BuildValue("{s:i,s:i,s:i,s:i,s:l,s:l,s:i,s:s}",
|
||||
"threads_per_core", info.threads_per_core,
|
||||
"cores_per_socket", info.cores_per_socket,
|
||||
"sockets_per_node", info.sockets_per_node,
|
||||
"nr_nodes", info.nr_nodes,
|
||||
"total_pages", info.total_pages,
|
||||
"free_pages", info.free_pages,
|
||||
"cpu_khz", info.cpu_khz);
|
||||
"cpu_khz", info.cpu_khz,
|
||||
"hw_caps", cpu_cap);
|
||||
}
|
||||
|
||||
static PyObject *pyxc_xeninfo(PyObject *self,
|
||||
@@ -715,7 +728,10 @@ static PyObject *pyxc_xeninfo(PyObject *self,
|
||||
xen_extraversion_t xen_extra;
|
||||
xen_compile_info_t xen_cc;
|
||||
xen_changeset_info_t xen_chgset;
|
||||
xen_capabilities_info_t xen_caps;
|
||||
xen_parameters_info_t xen_parms;
|
||||
long xen_version;
|
||||
char str[128];
|
||||
|
||||
xen_version = xc_version(xc->xc_handle, XENVER_version, NULL);
|
||||
|
||||
@@ -728,10 +744,20 @@ static PyObject *pyxc_xeninfo(PyObject *self,
|
||||
if ( xc_version(xc->xc_handle, XENVER_changeset, &xen_chgset) != 0 )
|
||||
return PyErr_SetFromErrno(xc_error);
|
||||
|
||||
return Py_BuildValue("{s:i,s:i,s:s,s:s,s:s,s:s,s:s,s:s}",
|
||||
if ( xc_version(xc->xc_handle, XENVER_capabilities, &xen_caps) != 0 )
|
||||
return PyErr_SetFromErrno(xc_error);
|
||||
|
||||
if ( xc_version(xc->xc_handle, XENVER_parameters, &xen_parms) != 0 )
|
||||
return PyErr_SetFromErrno(xc_error);
|
||||
|
||||
sprintf(str,"virt_start=0x%lx",xen_parms.virt_start);
|
||||
|
||||
return Py_BuildValue("{s:i,s:i,s:s,s:s,s:s,s:s,s:s,s:s,s:s,s:s}",
|
||||
"xen_major", xen_version >> 16,
|
||||
"xen_minor", (xen_version & 0xffff),
|
||||
"xen_extra", xen_extra,
|
||||
"xen_caps", xen_caps,
|
||||
"xen_params", str,
|
||||
"xen_changeset", xen_chgset,
|
||||
"cc_compiler", xen_cc.compiler,
|
||||
"cc_compile_by", xen_cc.compile_by,
|
||||
|
||||
@@ -58,20 +58,26 @@ class XendNode:
|
||||
|
||||
def physinfo(self):
|
||||
pinfo = self.xc.physinfo()
|
||||
info = [['cores_per_socket', pinfo['cores_per_socket']],
|
||||
info = [['nr_cpus', pinfo['nr_nodes']*pinfo['sockets_per_node']*pinfo['cores_per_socket']*pinfo['threads_per_core']],
|
||||
['nr_nodes', pinfo['nr_nodes']],
|
||||
['sockets_per_node', pinfo['sockets_per_node']],
|
||||
['cores_per_socket', pinfo['cores_per_socket']],
|
||||
['threads_per_core', pinfo['threads_per_core']],
|
||||
['cpu_mhz', pinfo['cpu_khz']/1000],
|
||||
['memory', pinfo['total_pages']/256],
|
||||
['free_memory', pinfo['free_pages']/256]]
|
||||
['cpu_mhz', pinfo['cpu_khz']/1000],
|
||||
['hw_caps', pinfo['hw_caps']],
|
||||
['memory', pinfo['total_pages']/256],
|
||||
['free_memory', pinfo['free_pages']/256]]
|
||||
return info
|
||||
|
||||
def xeninfo(self):
|
||||
xinfo = self.xc.xeninfo()
|
||||
return [['xen_major', xinfo['xen_major']],
|
||||
['xen_minor', xinfo['xen_minor']],
|
||||
['xen_extra', xinfo['xen_extra']],
|
||||
['xen_changeset', xinfo['xen_changeset']],
|
||||
['cc_compiler', xinfo['cc_compiler']],
|
||||
return [['xen_major', xinfo['xen_major']],
|
||||
['xen_minor', xinfo['xen_minor']],
|
||||
['xen_extra', xinfo['xen_extra']],
|
||||
['xen_caps', xinfo['xen_caps']],
|
||||
['xen_params',xinfo['xen_params']],
|
||||
['xen_changeset', xinfo['xen_changeset']],
|
||||
['cc_compiler', xinfo['cc_compiler']],
|
||||
['cc_compile_by', xinfo['cc_compile_by']],
|
||||
['cc_compile_domain', xinfo['cc_compile_domain']],
|
||||
['cc_compile_date', xinfo['cc_compile_date']]]
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <xen/console.h>
|
||||
#include <asm/shadow.h>
|
||||
#include <asm/irq.h>
|
||||
#include <asm/processor.h>
|
||||
#include <public/sched_ctl.h>
|
||||
|
||||
#include <asm/mtrr.h>
|
||||
@@ -34,13 +35,13 @@ static unsigned long msr_hi;
|
||||
|
||||
static void write_msr_for(void *unused)
|
||||
{
|
||||
if (((1 << current->processor) & msr_cpu_mask))
|
||||
if ( ((1 << current->processor) & msr_cpu_mask) )
|
||||
(void)wrmsr_user(msr_addr, msr_lo, msr_hi);
|
||||
}
|
||||
|
||||
static void read_msr_for(void *unused)
|
||||
{
|
||||
if (((1 << current->processor) & msr_cpu_mask))
|
||||
if ( ((1 << current->processor) & msr_cpu_mask) )
|
||||
(void)rdmsr_user(msr_addr, msr_lo, msr_hi);
|
||||
}
|
||||
|
||||
@@ -188,9 +189,11 @@ long arch_do_dom0_op(dom0_op_t *op, dom0_op_t *u_dom0_op)
|
||||
pi->total_pages = max_page;
|
||||
pi->free_pages = avail_domheap_pages();
|
||||
pi->cpu_khz = cpu_khz;
|
||||
|
||||
copy_to_user(u_dom0_op, op, sizeof(*op));
|
||||
memset(pi->hw_cap, 0, sizeof(pi->hw_cap));
|
||||
memcpy(pi->hw_cap, boot_cpu_data.x86_capability, NCAPINTS*4);
|
||||
ret = 0;
|
||||
if ( copy_to_user(u_dom0_op, op, sizeof(*op)) )
|
||||
ret = -EFAULT;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
+18
-2
@@ -3185,7 +3185,7 @@ int ptwr_do_page_fault(struct domain *d, unsigned long addr,
|
||||
struct pfn_info *page;
|
||||
l1_pgentry_t pte;
|
||||
l2_pgentry_t *pl2e, l2e;
|
||||
int which;
|
||||
int which, flags;
|
||||
unsigned long l2_idx;
|
||||
|
||||
if ( unlikely(shadow_mode_enabled(d)) )
|
||||
@@ -3206,8 +3206,24 @@ int ptwr_do_page_fault(struct domain *d, unsigned long addr,
|
||||
pfn = l1e_get_pfn(pte);
|
||||
page = &frame_table[pfn];
|
||||
|
||||
#ifdef CONFIG_X86_64
|
||||
#define WRPT_PTE_FLAGS (_PAGE_RW | _PAGE_PRESENT | _PAGE_USER)
|
||||
#else
|
||||
#define WRPT_PTE_FLAGS (_PAGE_RW | _PAGE_PRESENT)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Check the required flags for a valid wrpt mapping. If the page is
|
||||
* already writable then we can return straight to the guest (SMP race).
|
||||
* We decide whether or not to propagate the fault by testing for write
|
||||
* permissions in page directories by writing back to the linear mapping.
|
||||
*/
|
||||
if ( (flags = l1e_get_flags(pte) & WRPT_PTE_FLAGS) == WRPT_PTE_FLAGS )
|
||||
return !__put_user(
|
||||
pte.l1, &linear_pg_table[l1_linear_offset(addr)].l1);
|
||||
|
||||
/* We are looking only for read-only mappings of p.t. pages. */
|
||||
if ( ((l1e_get_flags(pte) & (_PAGE_RW|_PAGE_PRESENT)) != _PAGE_PRESENT) ||
|
||||
if ( ((flags | _PAGE_RW) != WRPT_PTE_FLAGS) ||
|
||||
((page->u.inuse.type_info & PGT_type_mask) != PGT_l1_page_table) ||
|
||||
((page->u.inuse.type_info & PGT_count_mask) == 0) ||
|
||||
(page_get_owner(page) != d) )
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
#include <xen/trace.h>
|
||||
#include <xen/multiboot.h>
|
||||
#include <xen/domain_page.h>
|
||||
#include <xen/compile.h>
|
||||
#include <public/version.h>
|
||||
#include <asm/bitops.h>
|
||||
#include <asm/smp.h>
|
||||
#include <asm/processor.h>
|
||||
@@ -529,6 +531,46 @@ void __init __start_xen(multiboot_info_t *mbi)
|
||||
startup_cpu_idle_loop();
|
||||
}
|
||||
|
||||
void arch_get_xen_caps(xen_capabilities_info_t info)
|
||||
{
|
||||
char *p = info;
|
||||
|
||||
#if defined(CONFIG_X86_32) && !defined(CONFIG_X86_PAE)
|
||||
|
||||
p += sprintf(p, "xen_%d.%d_x86_32 ", XEN_VERSION, XEN_SUBVERSION);
|
||||
if ( hvm_enabled )
|
||||
p += sprintf(p, "hvm_%d.%d_x86_32 ", XEN_VERSION, XEN_SUBVERSION);
|
||||
|
||||
#elif defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
|
||||
|
||||
p += sprintf(p, "xen_%d.%d_x86_32p ", XEN_VERSION, XEN_SUBVERSION);
|
||||
if ( hvm_enabled )
|
||||
{
|
||||
//p += sprintf(p, "hvm_%d.%d_x86_32 ", XEN_VERSION, XEN_SUBVERSION);
|
||||
//p += sprintf(p, "hvm_%d.%d_x86_32p ", XEN_VERSION, XEN_SUBVERSION);
|
||||
}
|
||||
|
||||
#elif defined(CONFIG_X86_64)
|
||||
|
||||
p += sprintf(p, "xen_%d.%d_x86_64 ", XEN_VERSION, XEN_SUBVERSION);
|
||||
if ( hvm_enabled )
|
||||
{
|
||||
//p += sprintf(p, "hvm_%d.%d_x86_32 ", XEN_VERSION, XEN_SUBVERSION);
|
||||
//p += sprintf(p, "hvm_%d.%d_x86_32p ", XEN_VERSION, XEN_SUBVERSION);
|
||||
p += sprintf(p, "hvm_%d.%d_x86_64 ", XEN_VERSION, XEN_SUBVERSION);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
p++;
|
||||
|
||||
#endif
|
||||
|
||||
*(p-1) = 0;
|
||||
|
||||
BUG_ON((p - info) > sizeof(info));
|
||||
}
|
||||
|
||||
/*
|
||||
* Local variables:
|
||||
* mode: C
|
||||
|
||||
+65
-50
@@ -470,20 +470,32 @@ static int handle_perdomain_mapping_fault(
|
||||
return EXCRET_fault_fixed;
|
||||
}
|
||||
|
||||
asmlinkage int do_page_fault(struct cpu_user_regs *regs)
|
||||
#ifdef HYPERVISOR_VIRT_END
|
||||
#define IN_HYPERVISOR_RANGE(va) \
|
||||
(((va) >= HYPERVISOR_VIRT_START) && ((va) < HYPERVISOR_VIRT_END))
|
||||
#else
|
||||
#define IN_HYPERVISOR_RANGE(va) \
|
||||
(((va) >= HYPERVISOR_VIRT_START))
|
||||
#endif
|
||||
|
||||
static int fixup_page_fault(unsigned long addr, struct cpu_user_regs *regs)
|
||||
{
|
||||
unsigned long addr, fixup;
|
||||
struct vcpu *v = current;
|
||||
struct vcpu *v = current;
|
||||
struct domain *d = v->domain;
|
||||
|
||||
__asm__ __volatile__ ("mov %%cr2,%0" : "=r" (addr) : );
|
||||
|
||||
DEBUGGER_trap_entry(TRAP_page_fault, regs);
|
||||
|
||||
perfc_incrc(page_faults);
|
||||
|
||||
if ( likely(VM_ASSIST(d, VMASST_TYPE_writable_pagetables) &&
|
||||
!shadow_mode_enabled(d)) )
|
||||
if ( unlikely(IN_HYPERVISOR_RANGE(addr)) )
|
||||
{
|
||||
if ( shadow_mode_external(d) && GUEST_CONTEXT(v, regs) )
|
||||
return shadow_fault(addr, regs);
|
||||
if ( (addr >= PERDOMAIN_VIRT_START) && (addr < PERDOMAIN_VIRT_END) )
|
||||
return handle_perdomain_mapping_fault(
|
||||
addr - PERDOMAIN_VIRT_START, regs);
|
||||
}
|
||||
else if ( unlikely(shadow_mode_enabled(d)) )
|
||||
{
|
||||
return shadow_fault(addr, regs);
|
||||
}
|
||||
else if ( likely(VM_ASSIST(d, VMASST_TYPE_writable_pagetables)) )
|
||||
{
|
||||
LOCK_BIGLOCK(d);
|
||||
if ( unlikely(d->arch.ptwr[PTWR_PT_ACTIVE].l1va) &&
|
||||
@@ -495,14 +507,9 @@ asmlinkage int do_page_fault(struct cpu_user_regs *regs)
|
||||
return EXCRET_fault_fixed;
|
||||
}
|
||||
|
||||
if ( ((addr < HYPERVISOR_VIRT_START)
|
||||
#if defined(__x86_64__)
|
||||
|| (addr >= HYPERVISOR_VIRT_END)
|
||||
#endif
|
||||
)
|
||||
&&
|
||||
KERNEL_MODE(v, regs) &&
|
||||
((regs->error_code & 3) == 3) && /* write-protection fault */
|
||||
if ( KERNEL_MODE(v, regs) &&
|
||||
/* Protection violation on write? No reserved-bit violation? */
|
||||
((regs->error_code & 0xb) == 0x3) &&
|
||||
ptwr_do_page_fault(d, addr, regs) )
|
||||
{
|
||||
UNLOCK_BIGLOCK(d);
|
||||
@@ -511,43 +518,51 @@ asmlinkage int do_page_fault(struct cpu_user_regs *regs)
|
||||
UNLOCK_BIGLOCK(d);
|
||||
}
|
||||
|
||||
if ( unlikely(shadow_mode_enabled(d)) &&
|
||||
((addr < HYPERVISOR_VIRT_START) ||
|
||||
#if defined(__x86_64__)
|
||||
(addr >= HYPERVISOR_VIRT_END) ||
|
||||
#endif
|
||||
(shadow_mode_external(d) && GUEST_CONTEXT(v, regs))) &&
|
||||
shadow_fault(addr, regs) )
|
||||
return EXCRET_fault_fixed;
|
||||
|
||||
if ( unlikely(addr >= PERDOMAIN_VIRT_START) &&
|
||||
unlikely(addr < PERDOMAIN_VIRT_END) &&
|
||||
handle_perdomain_mapping_fault(addr - PERDOMAIN_VIRT_START, regs) )
|
||||
return EXCRET_fault_fixed;
|
||||
|
||||
if ( !GUEST_MODE(regs) )
|
||||
goto xen_fault;
|
||||
|
||||
propagate_page_fault(addr, regs->error_code);
|
||||
return 0;
|
||||
}
|
||||
|
||||
xen_fault:
|
||||
/*
|
||||
* #PF error code:
|
||||
* Bit 0: Protection violation (=1) ; Page not present (=0)
|
||||
* Bit 1: Write access
|
||||
* Bit 2: Supervisor mode
|
||||
* Bit 3: Reserved bit violation
|
||||
* Bit 4: Instruction fetch
|
||||
*/
|
||||
asmlinkage int do_page_fault(struct cpu_user_regs *regs)
|
||||
{
|
||||
unsigned long addr, fixup;
|
||||
int rc;
|
||||
|
||||
if ( likely((fixup = search_exception_table(regs->eip)) != 0) )
|
||||
__asm__ __volatile__ ("mov %%cr2,%0" : "=r" (addr) : );
|
||||
|
||||
DEBUGGER_trap_entry(TRAP_page_fault, regs);
|
||||
|
||||
perfc_incrc(page_faults);
|
||||
|
||||
if ( unlikely((rc = fixup_page_fault(addr, regs)) != 0) )
|
||||
return rc;
|
||||
|
||||
if ( unlikely(!GUEST_MODE(regs)) )
|
||||
{
|
||||
perfc_incrc(copy_user_faults);
|
||||
regs->eip = fixup;
|
||||
return 0;
|
||||
if ( likely((fixup = search_exception_table(regs->eip)) != 0) )
|
||||
{
|
||||
perfc_incrc(copy_user_faults);
|
||||
regs->eip = fixup;
|
||||
return 0;
|
||||
}
|
||||
|
||||
DEBUGGER_trap_fatal(TRAP_page_fault, regs);
|
||||
|
||||
show_registers(regs);
|
||||
show_page_walk(addr);
|
||||
panic("CPU%d FATAL PAGE FAULT\n"
|
||||
"[error_code=%04x]\n"
|
||||
"Faulting linear address: %p\n",
|
||||
smp_processor_id(), regs->error_code, addr);
|
||||
}
|
||||
|
||||
DEBUGGER_trap_fatal(TRAP_page_fault, regs);
|
||||
|
||||
show_registers(regs);
|
||||
show_page_walk(addr);
|
||||
panic("CPU%d FATAL PAGE FAULT\n"
|
||||
"[error_code=%04x]\n"
|
||||
"Faulting linear address: %p\n",
|
||||
smp_processor_id(), regs->error_code, addr);
|
||||
propagate_page_fault(addr, regs->error_code);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -44,6 +44,8 @@
|
||||
|
||||
#include <public/io/ioreq.h>
|
||||
|
||||
int hvm_enabled;
|
||||
|
||||
#ifdef CONFIG_VMX
|
||||
|
||||
int vmcs_size;
|
||||
@@ -345,6 +347,8 @@ int start_vmx(void)
|
||||
|
||||
vmx_save_init_msrs();
|
||||
|
||||
hvm_enabled = 1;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,3 +19,6 @@ common.o: $(OBJS)
|
||||
|
||||
clean:
|
||||
rm -f *.o *~ core
|
||||
|
||||
# Object file contains changeset and compiler information.
|
||||
kernel.o: $(BASEDIR)/include/xen/compile.h
|
||||
+15
-5
@@ -113,14 +113,24 @@ long do_xen_version(int cmd, void *arg)
|
||||
|
||||
case XENVER_capabilities:
|
||||
{
|
||||
struct xen_capabilities_info info;
|
||||
|
||||
/* FIXME */
|
||||
info.arch = 0;
|
||||
info.pae = 0;
|
||||
xen_capabilities_info_t info;
|
||||
extern void arch_get_xen_caps(xen_capabilities_info_t info);
|
||||
|
||||
memset(info, 0, sizeof(info));
|
||||
arch_get_xen_caps(info);
|
||||
|
||||
if ( copy_to_user(arg, info, sizeof(info)) )
|
||||
return -EFAULT;
|
||||
return 0;
|
||||
}
|
||||
|
||||
case XENVER_parameters:
|
||||
{
|
||||
xen_parameters_info_t info = { .virt_start = HYPERVISOR_VIRT_START };
|
||||
if ( copy_to_user(arg, &info, sizeof(info)) )
|
||||
return -EFAULT;
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
case XENVER_changeset:
|
||||
|
||||
@@ -8,4 +8,5 @@ driver.o: $(OBJS)
|
||||
clean:
|
||||
rm -f *.o *~ core
|
||||
|
||||
# Object file contains changeset and compiler information.
|
||||
console.o: $(BASEDIR)/include/xen/compile.h
|
||||
@@ -98,9 +98,10 @@ struct pfn_info
|
||||
/* 16-bit count of uses of this frame as its current type. */
|
||||
#define PGT_count_mask ((1U<<16)-1)
|
||||
|
||||
#define PGT_mfn_mask ((1U<<20)-1) /* mfn mask for shadow types */
|
||||
/* 23-bit mfn mask for shadow types: good for up to 32GB RAM. */
|
||||
#define PGT_mfn_mask ((1U<<23)-1)
|
||||
|
||||
#define PGT_score_shift 20
|
||||
#define PGT_score_shift 23
|
||||
#define PGT_score_mask (((1U<<4)-1)<<PGT_score_shift)
|
||||
|
||||
/* Cleared when the owning guest 'frees' this page. */
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
|
||||
#include <public/io/ioreq.h>
|
||||
|
||||
extern int hvm_enabled;
|
||||
|
||||
extern void vmx_asm_vmexit_handler(struct cpu_user_regs);
|
||||
extern void vmx_asm_do_resume(void);
|
||||
extern void vmx_asm_do_launch(void);
|
||||
|
||||
@@ -213,6 +213,7 @@ typedef struct {
|
||||
u32 cpu_khz;
|
||||
unsigned long total_pages;
|
||||
unsigned long free_pages;
|
||||
u32 hw_cap[8];
|
||||
} dom0_physinfo_t;
|
||||
|
||||
/*
|
||||
|
||||
@@ -29,12 +29,14 @@ typedef struct xen_compile_info {
|
||||
} xen_compile_info_t;
|
||||
|
||||
#define XENVER_capabilities 3
|
||||
typedef struct xen_capabilities_info {
|
||||
int pae;
|
||||
int arch;
|
||||
} xen_capabilities_info_t;
|
||||
typedef char xen_capabilities_info_t[1024];
|
||||
|
||||
#define XENVER_changeset 4
|
||||
typedef char xen_changeset_info_t[64];
|
||||
|
||||
#define XENVER_parameters 5
|
||||
typedef struct xen_parameters_info {
|
||||
unsigned long virt_start;
|
||||
} xen_parameters_info_t;
|
||||
|
||||
#endif /* __XEN_PUBLIC_VERSION_H__ */
|
||||