Message ID | 50057A73.40005@linux.vnet.ibm.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On 07/17/2012 05:45 PM, Xiao Guangrong wrote: > In the later patch, it indicates failure when we try to get a writable > hva from the readonly slot > > Signed-off-by: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com> > --- > virt/kvm/kvm_main.c | 12 +++++++++++- > 1 files changed, 11 insertions(+), 1 deletions(-) > > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c > index b70f1a4..c056736 100644 > --- a/virt/kvm/kvm_main.c > +++ b/virt/kvm/kvm_main.c > @@ -994,9 +994,19 @@ static inline unsigned long bad_hva(void) > return PAGE_OFFSET; > } > > +static inline unsigned long readonly_bad_hva(void) > +{ > + return PAGE_OFFSET + PAGE_SIZE; > +} > + > +static int kvm_is_readonly_bad_hva(unsigned long addr) > +{ > + return addr == readonly_bad_hva(); > +} > + > int kvm_is_error_hva(unsigned long addr) > { > - return addr == bad_hva(); > + return addr == bad_hva() || kvm_is_readonly_bad_hva(addr); > } addr >= PAGE_OFFSET. Or change it to use -E*.
On 07/19/2012 06:16 PM, Avi Kivity wrote: > On 07/17/2012 05:45 PM, Xiao Guangrong wrote: >> In the later patch, it indicates failure when we try to get a writable >> hva from the readonly slot >> >> Signed-off-by: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com> >> --- >> virt/kvm/kvm_main.c | 12 +++++++++++- >> 1 files changed, 11 insertions(+), 1 deletions(-) >> >> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c >> index b70f1a4..c056736 100644 >> --- a/virt/kvm/kvm_main.c >> +++ b/virt/kvm/kvm_main.c >> @@ -994,9 +994,19 @@ static inline unsigned long bad_hva(void) >> return PAGE_OFFSET; >> } >> >> +static inline unsigned long readonly_bad_hva(void) >> +{ >> + return PAGE_OFFSET + PAGE_SIZE; >> +} >> + >> +static int kvm_is_readonly_bad_hva(unsigned long addr) >> +{ >> + return addr == readonly_bad_hva(); >> +} >> + >> int kvm_is_error_hva(unsigned long addr) >> { >> - return addr == bad_hva(); >> + return addr == bad_hva() || kvm_is_readonly_bad_hva(addr); >> } > > addr >= PAGE_OFFSET. Or change it to use -E*. I prefer to the first one, addr >= PAGE_OFFSET, all virtual addresses between 0 and (~0ULL) are valid, Using PAGE_OFFSET is more readable. [ is_error_pfn is suitable to use -err because the the range of physical address is always limited, for example, 0 ~ 64G on x86.] -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index b70f1a4..c056736 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -994,9 +994,19 @@ static inline unsigned long bad_hva(void) return PAGE_OFFSET; } +static inline unsigned long readonly_bad_hva(void) +{ + return PAGE_OFFSET + PAGE_SIZE; +} + +static int kvm_is_readonly_bad_hva(unsigned long addr) +{ + return addr == readonly_bad_hva(); +} + int kvm_is_error_hva(unsigned long addr) { - return addr == bad_hva(); + return addr == bad_hva() || kvm_is_readonly_bad_hva(addr); } EXPORT_SYMBOL_GPL(kvm_is_error_hva);
In the later patch, it indicates failure when we try to get a writable hva from the readonly slot Signed-off-by: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com> --- virt/kvm/kvm_main.c | 12 +++++++++++- 1 files changed, 11 insertions(+), 1 deletions(-)