Re: [Qemu-devel] [PATCH 2/2] ept_emulation_fault() need NetApp BSD attribution:
On 23/01/2018 13:36, Izik Eidus wrote: > Moving it to a new file and add the BSD license there. > > Signed-off-by: Izik EidusSince it's compatible, I'm just adding the NetApp BSD license to the file. What is the original source? xhyve or something like that? Paolo > --- > target/i386/hvf/ept_fault.h | 70 > + > target/i386/hvf/hvf.c | 38 +--- > 2 files changed, 71 insertions(+), 37 deletions(-) > create mode 100644 target/i386/hvf/ept_fault.h > > diff --git a/target/i386/hvf/ept_fault.h b/target/i386/hvf/ept_fault.h > new file mode 100644 > index 00..c2938d2bd4 > --- /dev/null > +++ b/target/i386/hvf/ept_fault.h > @@ -0,0 +1,70 @@ > +/*- > + * Copyright (c) 2011 NetApp, Inc. > + * All rights reserved. > + * > + * Redistribution and use in source and binary forms, with or without > + * modification, are permitted provided that the following conditions > + * are met: > + * 1. Redistributions of source code must retain the above copyright > + *notice, this list of conditions and the following disclaimer. > + * 2. Redistributions in binary form must reproduce the above copyright > + *notice, this list of conditions and the following disclaimer in the > + *documentation and/or other materials provided with the distribution. > + * > + * THIS SOFTWARE IS PROVIDED BY NETAPP, INC ``AS IS'' AND > + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE > + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > + * ARE DISCLAIMED. IN NO EVENT SHALL NETAPP, INC OR CONTRIBUTORS BE LIABLE > + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > + * SUCH DAMAGE. > + */ > + > +#ifndef EPT_FAULT_H > +#define EPT_FAULT_H > + > +#include "hvf-i386.h" > + > +static inline bool ept_emulation_fault(hvf_slot *slot, uint64_t gpa, > uint64_t ept_qual) > +{ > +int read, write; > + > +/* EPT fault on an instruction fetch doesn't make sense here */ > +if (ept_qual & EPT_VIOLATION_INST_FETCH) { > +return false; > +} > + > +/* EPT fault must be a read fault or a write fault */ > +read = ept_qual & EPT_VIOLATION_DATA_READ ? 1 : 0; > +write = ept_qual & EPT_VIOLATION_DATA_WRITE ? 1 : 0; > +if ((read | write) == 0) { > +return false; > +} > + > +if (write && slot) { > +if (slot->flags & HVF_SLOT_LOG) { > +memory_region_set_dirty(slot->region, gpa - slot->start, 1); > +hv_vm_protect((hv_gpaddr_t)slot->start, (size_t)slot->size, > + HV_MEMORY_READ | HV_MEMORY_WRITE); > +} > +} > + > +/* > + * The EPT violation must have been caused by accessing a > + * guest-physical address that is a translation of a guest-linear > + * address. > + */ > +if ((ept_qual & EPT_VIOLATION_GLA_VALID) == 0 || > +(ept_qual & EPT_VIOLATION_XLAT_VALID) == 0) { > +return false; > +} > + > +return !slot; > +} > + > + > +#endif > diff --git a/target/i386/hvf/hvf.c b/target/i386/hvf/hvf.c > index ab4820c3f5..94d8d119d5 100644 > --- a/target/i386/hvf/hvf.c > +++ b/target/i386/hvf/hvf.c > @@ -36,6 +36,7 @@ > #include "x86_emu.h" > #include "x86_task.h" > #include "x86hvf.h" > +#include "ept_fault.h" > > #include > #include > @@ -292,43 +293,6 @@ void hvf_cpu_synchronize_post_init(CPUState *cpu_state) > run_on_cpu(cpu_state, _hvf_cpu_synchronize_post_init, RUN_ON_CPU_NULL); > } > > -static bool ept_emulation_fault(hvf_slot *slot, uint64_t gpa, uint64_t > ept_qual) > -{ > -int read, write; > - > -/* EPT fault on an instruction fetch doesn't make sense here */ > -if (ept_qual & EPT_VIOLATION_INST_FETCH) { > -return false; > -} > - > -/* EPT fault must be a read fault or a write fault */ > -read = ept_qual & EPT_VIOLATION_DATA_READ ? 1 : 0; > -write = ept_qual & EPT_VIOLATION_DATA_WRITE ? 1 : 0; > -if ((read | write) == 0) { > -return false; > -} > - > -if (write && slot) { > -if (slot->flags & HVF_SLOT_LOG) { > -memory_region_set_dirty(slot->region, gpa - slot->start, 1); > -hv_vm_protect((hv_gpaddr_t)slot->start, (size_t)slot->size, > - HV_MEMORY_READ | HV_MEMORY_WRITE); > -} > -} > - > -/* > - * The EPT violation must have been caused by accessing a > - * guest-physical address that is a translation of a guest-linear > - * address. > - */ > -if ((ept_qual &
Re: [Qemu-devel] [PATCH 2/2] ept_emulation_fault() need NetApp BSD attribution:
On Fri, Jan 26, 2018 at 11:39 AM, Paolo Bonziniwrote: > On 23/01/2018 13:36, Izik Eidus wrote: >> Moving it to a new file and add the BSD license there. >> >> Signed-off-by: Izik Eidus > > Since it's compatible, I'm just adding the NetApp BSD license to the file. Sure. > > What is the original source? xhyve or something like that? This function is from freebsd: sys/amd64/vmm/intel/vmx.c http://web.mit.edu/freebsd/head/sys/amd64/vmm/intel/vmx.c Thanks. > > Paolo > >> --- >> target/i386/hvf/ept_fault.h | 70 >> + >> target/i386/hvf/hvf.c | 38 +--- >> 2 files changed, 71 insertions(+), 37 deletions(-) >> create mode 100644 target/i386/hvf/ept_fault.h >> >> diff --git a/target/i386/hvf/ept_fault.h b/target/i386/hvf/ept_fault.h >> new file mode 100644 >> index 00..c2938d2bd4 >> --- /dev/null >> +++ b/target/i386/hvf/ept_fault.h >> @@ -0,0 +1,70 @@ >> +/*- >> + * Copyright (c) 2011 NetApp, Inc. >> + * All rights reserved. >> + * >> + * Redistribution and use in source and binary forms, with or without >> + * modification, are permitted provided that the following conditions >> + * are met: >> + * 1. Redistributions of source code must retain the above copyright >> + *notice, this list of conditions and the following disclaimer. >> + * 2. Redistributions in binary form must reproduce the above copyright >> + *notice, this list of conditions and the following disclaimer in the >> + *documentation and/or other materials provided with the distribution. >> + * >> + * THIS SOFTWARE IS PROVIDED BY NETAPP, INC ``AS IS'' AND >> + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE >> + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR >> PURPOSE >> + * ARE DISCLAIMED. IN NO EVENT SHALL NETAPP, INC OR CONTRIBUTORS BE LIABLE >> + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR >> CONSEQUENTIAL >> + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS >> + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) >> + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, >> STRICT >> + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY >> + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF >> + * SUCH DAMAGE. >> + */ >> + >> +#ifndef EPT_FAULT_H >> +#define EPT_FAULT_H >> + >> +#include "hvf-i386.h" >> + >> +static inline bool ept_emulation_fault(hvf_slot *slot, uint64_t gpa, >> uint64_t ept_qual) >> +{ >> +int read, write; >> + >> +/* EPT fault on an instruction fetch doesn't make sense here */ >> +if (ept_qual & EPT_VIOLATION_INST_FETCH) { >> +return false; >> +} >> + >> +/* EPT fault must be a read fault or a write fault */ >> +read = ept_qual & EPT_VIOLATION_DATA_READ ? 1 : 0; >> +write = ept_qual & EPT_VIOLATION_DATA_WRITE ? 1 : 0; >> +if ((read | write) == 0) { >> +return false; >> +} >> + >> +if (write && slot) { >> +if (slot->flags & HVF_SLOT_LOG) { >> +memory_region_set_dirty(slot->region, gpa - slot->start, 1); >> +hv_vm_protect((hv_gpaddr_t)slot->start, (size_t)slot->size, >> + HV_MEMORY_READ | HV_MEMORY_WRITE); >> +} >> +} >> + >> +/* >> + * The EPT violation must have been caused by accessing a >> + * guest-physical address that is a translation of a guest-linear >> + * address. >> + */ >> +if ((ept_qual & EPT_VIOLATION_GLA_VALID) == 0 || >> +(ept_qual & EPT_VIOLATION_XLAT_VALID) == 0) { >> +return false; >> +} >> + >> +return !slot; >> +} >> + >> + >> +#endif >> diff --git a/target/i386/hvf/hvf.c b/target/i386/hvf/hvf.c >> index ab4820c3f5..94d8d119d5 100644 >> --- a/target/i386/hvf/hvf.c >> +++ b/target/i386/hvf/hvf.c >> @@ -36,6 +36,7 @@ >> #include "x86_emu.h" >> #include "x86_task.h" >> #include "x86hvf.h" >> +#include "ept_fault.h" >> >> #include >> #include >> @@ -292,43 +293,6 @@ void hvf_cpu_synchronize_post_init(CPUState *cpu_state) >> run_on_cpu(cpu_state, _hvf_cpu_synchronize_post_init, RUN_ON_CPU_NULL); >> } >> >> -static bool ept_emulation_fault(hvf_slot *slot, uint64_t gpa, uint64_t >> ept_qual) >> -{ >> -int read, write; >> - >> -/* EPT fault on an instruction fetch doesn't make sense here */ >> -if (ept_qual & EPT_VIOLATION_INST_FETCH) { >> -return false; >> -} >> - >> -/* EPT fault must be a read fault or a write fault */ >> -read = ept_qual & EPT_VIOLATION_DATA_READ ? 1 : 0; >> -write = ept_qual & EPT_VIOLATION_DATA_WRITE ? 1 : 0; >> -if ((read | write) == 0) { >> -return false; >> -} >> - >> -if (write && slot) { >> -if (slot->flags & HVF_SLOT_LOG) { >> -memory_region_set_dirty(slot->region, gpa - slot->start, 1); >> -