s390: Reintroduce support for DCACHE_WORD_ACCESS
Heiko Carstens
maintainercover s390: Reintroduce support for DCACHE_WORD_ACCESS
Support for DCACHE_WORD_ACCESS was recently removed [1] since it caused problems with the incomplete handling of secure storage access exceptions. It looked like fixing the exception handler would be a larger effort; therefore support for DCACHE_WORD_ACCESS was removed as a work around.
Address the potential problems that exist with secure storage access exceptions and add support for DCACHE_WORD_ACCESS again.
In particular address the following problems:
- Reading the guest variable storage area via the /proc/kcore interface results in short reads. Address this by using a VM_SPARSE area for the guest variable storage area. VM_SPARSE areas will be handled like memory holes (zeros will be read).
- Fix handling of secure storage access exceptions in vmalloc area.
- Remove folio handling for secure storage access exceptions to avoid potential data corruption.
[1] 37540b8c287f ("s390: Revert support for DCACHE_WORD_ACCESS")
Heiko Carstens (4):
KVM: s390: pv: Use VM_SPARSE area for guest variable storage area s390/mm: Fix handling of secure storage access exceptions in vmalloc area s390/mm: Remove folio handling for secure storage access exceptions
s390: Add support for DCACHE_WORD_ACCESS (again)
arch/s390/Kconfig | 1 + arch/s390/include/asm/asm-extable.h | 4 ++ arch/s390/include/asm/uv.h | 2 + arch/s390/include/asm/word-at-a-time.h | 22 ++++++++++ arch/s390/kernel/uv.c | 59 ++++++++++++++++++++++++++ arch/s390/kvm/pv.c | 6 +-- arch/s390/mm/extable.c | 18 ++++++++ arch/s390/mm/fault.c | 10 ++--- 8 files changed, 112 insertions(+), 10 deletions(-)
Signature · 1 line
2.53.0
Heiko Carstens
maintainerPATCH 1/4 KVM: s390: pv: Use VM_SPARSE area for guest variable storage area
The guest variable storage area is allocated with vmalloc and then donated to the ultravisor. Any kernel access to that area will result in a secure storage access exception (aka fault).
This is a problem if such a memory area is read via /proc/kcore. This causes an exception via vread_iter() and results in an unexpected short read. Avoid this by allocating a custom VM_SPARSE area. If such an area is read, vread_iter() returns zeroes for the entire area.
--- arch/s390/include/asm/uv.h | 2 ++ arch/s390/kernel/uv.c | 59 ++++++++++++++++++++++++++++++++++++++ arch/s390/kvm/pv.c | 6 ++-- 3 files changed, 64 insertions(+), 3 deletions(-)
arch/s390/include/asm/uv.h +2 -0
@@ -635,6 +635,8 @@ int s390_wiggle_split_folio(struct mm_struct *mm, struct folio *folio);int __make_folio_secure (struct folio *folio,struct uv_cb_header *uvcb);int uv_convert_from_secure (unsigned long paddr);int uv_convert_from_secure_folio (struct folio *folio); +void *uv_alloc_stor_var (unsigned long size); +void uv_free_stor_var (void *stor_var);void setup_uv (void );
arch/s390/kernel/uv.c +59 -0
71 lines not on this page · raw message
arch/s390/kvm/pv.c +3 -3
@@ -337,7 +337,7 @@ int kvm_s390_pv_create_cpu(struct kvm_vcpu *vcpu, u16 *rc, u16 *rrc)/* only free resources when the destroy was successful */ static void kvm_s390_pv_dealloc_vm (struct kvm *kvm) { -vfree (kvm->arch.pv.stor_var); +uv_free_stor_var (kvm->arch.pv.stor_var);free_pages (kvm->arch.pv.stor_base,get_order (uv_info.guest_base_stor_len));kvm_s390_clear_pv_state (kvm);
@@ -369,7 +369,7 @@ static int kvm_s390_pv_alloc_vm(struct kvm *kvm)/* Allocate variable storage */ vlen =ALIGN (virt * ((npages *PAGE_SIZE ) /HPAGE_SIZE ),PAGE_SIZE ); vlen += uv_info.guest_virt_base_stor_len; - kvm->arch.pv.stor_var =vzalloc (vlen); + kvm->arch.pv.stor_var =uv_alloc_stor_var (vlen);if (!kvm->arch.pv.stor_var) goto out_err;return 0 ;
@@ -414,7 +414,7 @@ static int kvm_s390_pv_dispose_one_leftover(struct kvm *kvm,*/ free_pages (leftover->stor_base,get_order (uv_info.guest_base_stor_len));free_pages (leftover->old_gmap_table,CRST_ALLOC_ORDER ); -vfree (leftover->stor_var); +uv_free_stor_var (leftover->stor_var); done_fast:atomic_dec (&kvm->mm->context.protected_count);return 0 ;
Signature · 1 line
2.53.0
Heiko Carstens
maintainerPATCH 2/4 s390/mm: Fix handling of secure storage access exceptions in vmalloc area
In reply to Heiko CarstensSecure storage access exceptions in vmalloc area need to be handled separately since folio_try_get() or virt_to_phys() do not work on such addresses. Given that there cannot be a valid access let such exceptions fail immediately. The kernel will either fixup or crash.
--- arch/s390/mm/fault.c | 2 ++ 1 file changed, 2 insertions(+)
arch/s390/mm/fault.c +2 -0
@@ -438,6 +438,8 @@ void do_secure_storage_access(struct pt_regs *regs)panic ("Unexpected PGM 0x3d with TEID bit 61=0" ); }if (is_kernel_fault (regs)) { +if (is_vmalloc_addr ((void *)addr)) +return handle_fault_error_nolock (regs,0 ); folio =virt_to_folio ((void *)addr);if (unlikely (!folio_try_get (folio)))return ;
Signature · 1 line
2.53.0
Heiko Carstens
maintainerPATCH 3/4 s390/mm: Remove folio handling for secure storage access exceptions
In reply to Heiko CarstensRemove folio handling for secure storage access exceptions that happen via the kernel mapping. Using folio_try_get() for exceptions via the kernel mapping is racy: for example such an exception may happen on one CPU, while a different CPU frees the corresponding page. Subsequently the page can be part of a folio of different size, before the faulting CPU executes folio_try_get(). This may lead to data corruption.
As of now this scenario does not seem to be possible, however with the upcoming load_unaligned_zeropad() this is possible.
As a side effect PG_arch_1 is not cleared anymore for such faults via the kernel mapping. However given that this bit is over-indicating it shouldn't matter.
--- arch/s390/mm/fault.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
arch/s390/mm/fault.c +1 -7
@@ -440,13 +440,7 @@ void do_secure_storage_access(struct pt_regs *regs)if (is_kernel_fault (regs)) {if (is_vmalloc_addr ((void *)addr))return handle_fault_error_nolock (regs,0 ); - folio =virt_to_folio ((void *)addr); -if (unlikely (!folio_try_get (folio))) -return ; - rc =uv_convert_from_secure (folio_to_phys (folio)); -if (!rc) -clear_bit (PG_arch_1, &folio->flags.f); -folio_put (folio); + rc =uv_convert_from_secure (__pa (addr));/* * There are some valid fixup types for kernel * accesses to donated secure memory. zeropad is one
Signature · 1 line
2.53.0
Heiko Carstens
maintainerPATCH 4/4 s390: Add support for DCACHE_WORD_ACCESS (again)
In reply to Heiko CarstensImplement load_unaligned_zeropad() and enable DCACHE_WORD_ACCESS to speed up string operations in fs/dcache.c and fs/namei.c.
With the secure storage access exception cases addressed, add support for DCACHE_WORD_ACCESS again.
--- arch/s390/Kconfig | 1 + arch/s390/include/asm/asm-extable.h | 4 ++++ arch/s390/include/asm/word-at-a-time.h | 22 ++++++++++++++++++++++ arch/s390/mm/extable.c | 18 ++++++++++++++++++ 4 files changed, 45 insertions(+)
arch/s390/Kconfig +1 -0
@@ -163,6 +163,7 @@ config S390 select ARCH_WANTS_THP_SWAP select BUILDTIME_TABLE_SORT select CLONE_BACKWARDS2 + select DCACHE_WORD_ACCESS if !KMSAN select DYNAMIC_FTRACE if FUNCTION_TRACER select FUNCTION_ALIGNMENT_8B if CC_IS_GCC select FUNCTION_ALIGNMENT_16B if !CC_IS_GCC
arch/s390/include/asm/asm-extable.h +4 -0
@@ -12,6 +12,7 @@#define EX_TYPE_UA_FAULT 3#define EX_TYPE_UA_LOAD_REG 5#define EX_TYPE_UA_LOAD_REGPAIR 6 +#define EX_TYPE_ZEROPAD 7#define EX_TYPE_FPC 8#define EX_TYPE_UA_MVCOS_TO 9#define EX_TYPE_UA_MVCOS_FROM 10
@@ -79,6 +80,9 @@#define EX_TABLE_UA_LOAD_REGPAIR (_fault, _target, _regerr, _regzero) \ __EX_TABLE(__ex_table, _fault, _target, EX_TYPE_UA_LOAD_REGPAIR, _regerr, _regzero, 0) +#define EX_TABLE_ZEROPAD (_fault, _target, _regdata, _regaddr) \ + __EX_TABLE(__ex_table, _fault, _target, EX_TYPE_ZEROPAD, _regdata, _regaddr, 0) +#define EX_TABLE_FPC (_fault, _target) \ __EX_TABLE(__ex_table, _fault, _target, EX_TYPE_FPC, __stringify(%%r0), __stringify(%%r0), 0)
arch/s390/include/asm/word-at-a-time.h +22 -0
@@ -4,6 +4,7 @@#include <linux/bitops.h> #include <linux/wordpart.h> +#include <asm/asm-extable.h> #include <asm/bitsperlong.h> struct word_at_a_time {
@@ -40,4 +41,25 @@ static inline unsigned long zero_bytemask(unsigned long data) return ~1UL << data; } +/* +* Load an unaligned word from kernel space. +* +* In the (very unlikely) case of the word being a page-crosser +* and the next page not being mapped, take the exception and +* return zeroes in the non-existing part. +*/ +static inline unsigned long load_unaligned_zeropad (const void *addr) +{ +unsigned long data; + + asm_inline volatile( +"0: lg %[data],0(%[addr])\n" +"1: nopr %%r7\n" + EX_TABLE_ZEROPAD(0b, 1b, %[data], %[addr]) + EX_TABLE_ZEROPAD(1b, 1b, %[data], %[addr]) + : [data] "=d" (data) + : [addr] "a" (addr), "m" (*(unsigned long *)addr)); +return data; +} +#endif /* _ASM_WORD_AT_A_TIME_H */
arch/s390/mm/extable.c +18 -0
@@ -50,6 +50,22 @@ static bool ex_handler_ua_load_reg(const struct exception_table_entry *ex,return true; } +static bool ex_handler_zeropad (const struct exception_table_entry *ex,struct pt_regs *regs) +{ +unsigned int reg_addr =FIELD_GET (EX_DATA_REG_ADDR , ex->data); +unsigned int reg_data =FIELD_GET (EX_DATA_REG_ERR , ex->data); +unsigned long data, addr, offset; + + addr = regs->gprs[reg_addr]; + offset = addr & (sizeof (unsigned long ) -1 ); + addr &= ~(sizeof (unsigned long ) -1 ); + data = *(unsigned long *)addr; + data <<=BITS_PER_BYTE * offset; + regs->gprs[reg_data] = data; + regs->psw.addr =extable_fixup (ex); +return true; +} +static bool ex_handler_fpc (const struct exception_table_entry *ex,struct pt_regs *regs) {fpu_sfpc (0 );
@@ -118,6 +134,8 @@ bool fixup_exception(struct pt_regs *regs)return ex_handler_ua_load_reg (ex, false, regs);case EX_TYPE_UA_LOAD_REGPAIR :return ex_handler_ua_load_reg (ex, true, regs); +case EX_TYPE_ZEROPAD : +return ex_handler_zeropad (ex, regs);case EX_TYPE_FPC :return ex_handler_fpc (ex, regs);case EX_TYPE_UA_MVCOS_TO :
Signature · 1 line
2.53.0
David Hildenbrand (Arm)
reviewerRe: [PATCH 3/4] s390/mm: Remove folio handling for secure storage access exceptions
In reply to Heiko CarstensQuoted 6 lines · Heiko Carstens
Remove folio handling for secure storage access exceptions that happen via the kernel mapping. Using
folio_try_get()for exceptions via the kernel mapping is racy: for example such an exception may happen on one CPU, while a different CPU frees the corresponding page. Subsequently the page can be part of a folio of different size, before the faulting CPU executesfolio_try_get(). This may lead to data corruption.
Right, that's why one would have to re-verify whether the page is still part of the folio afterwards.
Signature · 3 lines
Cheers, David
[email protected]
AI reviewRe: [PATCH 1/4] KVM: s390: pv: Use VM_SPARSE area for guest variable storage area
In reply to Heiko CarstensThank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [High] Physical pages are freed to the buddy allocator before their corresponding page table entries are…
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Physical pages are freed to the buddy allocator before their corresponding page table entries are cleared and the TLB is flushed, creating a Use-After-Free vulnerability window.
- [High] Passing an unaligned size to uv_alloc_stor_var() causes an infinite loop in the kernel page table walker.
--
--- Patch [1]: [PATCH 1/4] KVM: s390: pv: Use VM_SPARSE area for guest variable storage area --- commit fd3cc6954f3085a22cae9f0932705a2913ea0050
Author: Heiko Carstens <[email protected]>
KVM: s390: pv: Use VM_SPARSE area for guest variable storage area
The guest variable storage area is allocated with vmalloc and then donated to the ultravisor. This patch allocates it via a custom VM_SPARSE area to avoid unexpected short reads via /proc/kcore.
Quoted 4 lines
arch/s390/kernel/uv.c +0
-0
[ ... ]
Quoted 18 lines
arch/s390/kernel/uv.c +14
-0@@ -209,6 +210,64 @@ int uv_convert_from_secure_pte(pte_t pte)return uv_convert_from_secure_folio (pfn_folio (pte_pfn (pte))); } +static int uv_free_range_cb (pte_t *ptep,unsigned long addr,void *data) +{ +pte_t pte =ptep_get (ptep); + +if (!pte_present (pte)) +return 0 ; +__free_page (pte_page (pte)); +return 0 ; +} + +void uv_free_stor_var (void *stor_var) +{ +unsigned long addr, size; +struct vm_struct *area;
arch/s390/kernel/uv.c int uv_convert_from_secure_pte(pte_t pte) · line 236
Quoted 10 lines
arch/s390/kernel/uv.c +10
-0+ +if (!stor_var) +return ; + area =find_vm_area (stor_var); +if (WARN_ON_ONCE (!area || !(area->flags &VM_SPARSE ))) +return ; + size =get_vm_area_size (area); + addr = (unsigned long )area->addr; +apply_to_existing_page_range (&init_mm, addr, size, uv_free_range_cb,NULL ); +free_vm_area (area);
[Severity: High]
Does this create a Use-After-Free window during VM teardown?
In uv_free_stor_var(), we call apply_to_existing_page_range() which invokes uv_free_range_cb() for each page. The callback frees the physical page directly to the buddy allocator via __free_page() while the PTE remains fully present and writable in the init_mm page tables.
After all pages are freed, free_vm_area() is called to clear the PTEs and flush the TLB. If a freed page is immediately reallocated to another subsystem, can concurrent accesses via the stale vmalloc alias read or overwrite the newly reallocated page before free_vm_area() completes?
Quoted 2 lines
arch/s390/kernel/uv.c +2
-0+} +EXPORT_SYMBOL_FOR_MODULES (uv_free_stor_var,"kvm" );
[ ... ]
arch/s390/kernel/uv.c int uv_convert_from_secure_pte(pte_t pte) · line 262
Quoted 10 lines
arch/s390/kernel/uv.c +10
-0+void *uv_alloc_stor_var (unsigned long size) +{ +struct vm_struct *area; +unsigned long addr; + + area =get_vm_area (size,VM_SPARSE ); +if (!area) +return NULL ; + addr = (unsigned long )area->addr; +if (apply_to_page_range (&init_mm, addr, size, uv_alloc_range_cb,NULL ))
[Severity: High]
If an unaligned size is passed to uv_alloc_stor_var(), could this cause an infinite loop in the page table walker?
The size parameter is passed directly to apply_to_page_range(). The internal page table walker loop relies on the end boundary being exactly page-aligned to terminate:
do {
...
} while (pte++, addr += PAGE_SIZE, addr != end);If size is not a multiple of PAGE_SIZE, addr will increment past end without matching it, looping indefinitely over the page tables.
Should we pass the page-aligned size of the allocated VM area instead, perhaps by using get_vm_area_size(area) or explicitly aligning size beforehand?
Quoted 7 lines
arch/s390/kernel/uv.c +7
-0+ goto out; +return area->addr; +out: +uv_free_stor_var (area->addr); +return NULL ; +} +EXPORT_SYMBOL_FOR_MODULES (uv_alloc_stor_var,"kvm" );
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Am 16.07.26 um 16:14 schrieb Heiko Carstens:
Quoted 21 lines
Support for
DCACHE_WORD_ACCESSwas recently removed [1] since it caused problems with the incomplete handling of secure storage access exceptions. It looked like fixing the exception handler would be a larger effort; therefore support forDCACHE_WORD_ACCESSwas removed as a work around.Address the potential problems that exist with secure storage access exceptions and add support for
DCACHE_WORD_ACCESSagain.In particular address the following problems:
- Reading the guest variable storage area via the
/proc/kcoreinterface results in short reads. Address this by using aVM_SPARSEarea for the guest variable storage area.VM_SPARSEareas will be handled like memory holes (zeros will be read).- Fix handling of secure storage access exceptions in vmalloc area.
- Remove folio handling for secure storage access exceptions to avoid potential data corruption.
Quoted 7 lines
[1]
37540b8c287f("s390: Revert support forDCACHE_WORD_ACCESS")Heiko Carstens (4):
KVM: s390: pv: UseVM_SPARSEarea for guest variable storage area s390/mm: Fix handling of secure storage access exceptions in vmalloc area s390/mm: Remove folio handling for secure storage access exceptions
s390: Add support forDCACHE_WORD_ACCESS(again)
Whole series
with a kernel module and a hacked up kselftest.
Quoted 11 lines
arch/s390/Kconfig | 1 + arch/s390/include/asm/asm-extable.h | 4 ++ arch/s390/include/asm/uv.h | 2 + arch/s390/include/asm/word-at-a-time.h | 22 ++++++++++ arch/s390/kernel/uv.c | 59 ++++++++++++++++++++++++++ arch/s390/kvm/pv.c | 6 +-- arch/s390/mm/extable.c | 18 ++++++++ arch/s390/mm/fault.c | 10 ++--- 8 files changed, 112 insertions(+), 10 deletions(-)
Christian Borntraeger
maintainerRe: [PATCH 1/4] KVM: s390: pv: Use VM_SPARSE area for guest variable storage area
In reply to [email protected]Am 16.07.26 um 16:33 schrieb [email protected]:
[...]
Quoted 23 lines
Quoted 4 lines
arch/s390/kernel/uv.c +4
-0+void uv_free_stor_var (void *stor_var) +{ +unsigned long addr, size; +struct vm_struct *area;arch/s390/kernel/uv.c int uv_convert_from_secure_pte(pte_t pte) · line 236
Quoted 10 lines
arch/s390/kernel/uv.c +10
-0+ +if (!stor_var) +return ; + area =find_vm_area (stor_var); +if (WARN_ON_ONCE (!area || !(area->flags &VM_SPARSE ))) +return ; + size =get_vm_area_size (area); + addr = (unsigned long )area->addr; +apply_to_existing_page_range (&init_mm, addr, size, uv_free_range_cb,NULL ); +free_vm_area (area);[Severity: High]
Does this create a Use-After-Free window during VM teardown?In
uv_free_stor_var(), we callapply_to_existing_page_range()which invokesuv_free_range_cb()for each page. The callback frees the physical page directly to the buddy allocator via__free_page()while the PTE remains fully present and writable in theinit_mmpage tables.
Quoted 4 lines
After all pages are freed,
free_vm_area()is called to clear the PTEs and flush the TLB. If a freed page is immediately reallocated to another subsystem, can concurrent accesses via the stale vmalloc alias read or overwrite the newly reallocated page beforefree_vm_area()completes?
I guess this is a very very theoretical problem. Not sure if we really want to address this. The necessary allocation in a freeing function might be worse than temporary access via the kernel mapping.
Quoted 21 lines
Quoted 3 lines
(quoted diff) +2
-0+} +EXPORT_SYMBOL_FOR_MODULES(uv_free_stor_var, "kvm");[ ... ]
arch/s390/kernel/uv.c int uv_convert_from_secure_pte(pte_t pte) · line 262
Quoted 10 lines
arch/s390/kernel/uv.c +10
-0+void *uv_alloc_stor_var (unsigned long size) +{ +struct vm_struct *area; +unsigned long addr; + + area =get_vm_area (size,VM_SPARSE ); +if (!area) +return NULL ; + addr = (unsigned long )area->addr; +if (apply_to_page_range (&init_mm, addr, size, uv_alloc_range_cb,NULL ))[Severity: High]
If an unaligned size is passed touv_alloc_stor_var(), could this cause an infinite loop in the page table walker?
Quoted 3 lines
The size parameter is passed directly to
apply_to_page_range(). The internal page table walker loop relies on the end boundary being exactly page-aligned to terminate:
This is one of those things that wont happen in reality as the returned sized will be aligned, but as the interface for base variable storage returns bytes and in theory _COULD_ be unaligned
maybe change belows hunk to
@@ -369,7 +369,7 @@ static int kvm_s390_pv_alloc_vm(struct kvm *kvm)
/* Allocate variable storage */
vlen = ALIGN(virt * ((npages * PAGE_SIZE) / HPAGE_SIZE), PAGE_SIZE);
----> vlen += uv_info.guest_virt_base_stor_len; <--- also add ALIGN here
- kvm->arch.pv.stor_var = vzalloc(vlen);
+ kvm->arch.pv.stor_var = uv_alloc_stor_var(vlen);
if (!kvm->arch.pv.stor_var)
goto out_err;
return 0;
Could also be a separate patch if we want to.
Heiko Carstens
maintainerRe: [PATCH 1/4] KVM: s390: pv: Use VM_SPARSE area for guest variable storage area
Quoted 10 lines · Christian Borntraeger
Am 16.07.26 um 16:33 schrieb [email protected]:
[...]Quoted 8 lines
[Severity: High]
Does this create a Use-After-Free window during VM teardown?In
uv_free_stor_var(), we callapply_to_existing_page_range()which invokesuv_free_range_cb()for each page. The callback frees the physical page directly to the buddy allocator via__free_page()while the PTE remains fully present and writable in theinit_mmpage tables.
Quoted 8 lines
Quoted 4 lines
After all pages are freed,
free_vm_area()is called to clear the PTEs and flush the TLB. If a freed page is immediately reallocated to another subsystem, can concurrent accesses via the stale vmalloc alias read or overwrite the newly reallocated page beforefree_vm_area()completes?I guess this is a very very theoretical problem. Not sure if we really want to address this. The necessary allocation in a freeing function might be worse than temporary access via the kernel mapping.
I added a comment why this won't be addressed. The existing vmalloc code already implements lazy TLB flushing (even though it is not active on only s390 because of our special ptep_get_and_clear() implementation).
Quoted 34 lines
Quoted 15 lines
arch/s390/kernel/uv.c int uv_convert_from_secure_pte(pte_t pte) · line 262
Quoted 10 lines
arch/s390/kernel/uv.c +10
-0+void *uv_alloc_stor_var (unsigned long size) +{ +struct vm_struct *area; +unsigned long addr; + + area =get_vm_area (size,VM_SPARSE ); +if (!area) +return NULL ; + addr = (unsigned long )area->addr; +if (apply_to_page_range (&init_mm, addr, size, uv_alloc_range_cb,NULL ))[Severity: High]
If an unaligned size is passed touv_alloc_stor_var(), could this cause an infinite loop in the page table walker?Quoted 3 lines
The size parameter is passed directly to
apply_to_page_range(). The internal page table walker loop relies on the end boundary being exactly page-aligned to terminate:This is one of those things that wont happen in reality as the returned sized will be aligned, but as the interface for base variable storage returns bytes and in theory _COULD_ be unaligned
maybe change belows hunk toarch/s390/kvm/pv.c +1
-2@@ -369,7 +369,7 @@ static int kvm_s390_pv_alloc_vm(struct kvm *kvm)/* Allocate variable storage */ vlen =ALIGN (virt * ((npages *PAGE_SIZE ) /HPAGE_SIZE ),PAGE_SIZE ); ----> vlen += uv_info.guest_virt_base_stor_len; <--- also add ALIGN here - kvm->arch.pv.stor_var = vzalloc(vlen); + kvm->arch.pv.stor_var =uv_alloc_stor_var (vlen);if (!kvm->arch.pv.stor_var) goto out_err;return 0 ;
Quoted 1 line
Could also be a separate patch if we want to.
I added the alignment handling uv_alloc_stor_var(), so that it doesn't matter what callers pass.