Skip to content

Commit fae3f6f

Browse files
committed
Merge branch 'for-linus' of git://git390.marist.edu/pub/scm/linux-2.6
* 'for-linus' of git://git390.marist.edu/pub/scm/linux-2.6: [S390] kvm: extension capability for new address space layout [S390] kvm: fix address mode switching
2 parents d93dc5c + b6cf878 commit fae3f6f

6 files changed

Lines changed: 17 additions & 10 deletions

File tree

arch/s390/include/asm/pgtable.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -658,12 +658,14 @@ static inline void pgste_set_pte(pte_t *ptep, pgste_t pgste)
658658
* struct gmap_struct - guest address space
659659
* @mm: pointer to the parent mm_struct
660660
* @table: pointer to the page directory
661+
* @asce: address space control element for gmap page table
661662
* @crst_list: list of all crst tables used in the guest address space
662663
*/
663664
struct gmap {
664665
struct list_head list;
665666
struct mm_struct *mm;
666667
unsigned long *table;
668+
unsigned long asce;
667669
struct list_head crst_list;
668670
};
669671

arch/s390/kernel/asm-offsets.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <linux/sched.h>
1111
#include <asm/vdso.h>
1212
#include <asm/sigp.h>
13+
#include <asm/pgtable.h>
1314

1415
/*
1516
* Make sure that the compiler is new enough. We want a compiler that
@@ -126,6 +127,7 @@ int main(void)
126127
DEFINE(__LC_KERNEL_STACK, offsetof(struct _lowcore, kernel_stack));
127128
DEFINE(__LC_ASYNC_STACK, offsetof(struct _lowcore, async_stack));
128129
DEFINE(__LC_PANIC_STACK, offsetof(struct _lowcore, panic_stack));
130+
DEFINE(__LC_USER_ASCE, offsetof(struct _lowcore, user_asce));
129131
DEFINE(__LC_INT_CLOCK, offsetof(struct _lowcore, int_clock));
130132
DEFINE(__LC_MCCK_CLOCK, offsetof(struct _lowcore, mcck_clock));
131133
DEFINE(__LC_MACHINE_FLAGS, offsetof(struct _lowcore, machine_flags));
@@ -151,6 +153,7 @@ int main(void)
151153
DEFINE(__LC_VDSO_PER_CPU, offsetof(struct _lowcore, vdso_per_cpu_data));
152154
DEFINE(__LC_GMAP, offsetof(struct _lowcore, gmap));
153155
DEFINE(__LC_CMF_HPP, offsetof(struct _lowcore, cmf_hpp));
156+
DEFINE(__GMAP_ASCE, offsetof(struct gmap, asce));
154157
#endif /* CONFIG_32BIT */
155158
return 0;
156159
}

arch/s390/kernel/entry64.S

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,13 +1076,19 @@ sie_loop:
10761076
lg %r14,__LC_THREAD_INFO # pointer thread_info struct
10771077
tm __TI_flags+7(%r14),_TIF_EXIT_SIE
10781078
jnz sie_exit
1079+
lg %r14,__LC_GMAP # get gmap pointer
1080+
ltgr %r14,%r14
1081+
jz sie_gmap
1082+
lctlg %c1,%c1,__GMAP_ASCE(%r14) # load primary asce
1083+
sie_gmap:
10791084
lg %r14,__SF_EMPTY(%r15) # get control block pointer
10801085
SPP __SF_EMPTY(%r15) # set guest id
10811086
sie 0(%r14)
10821087
sie_done:
10831088
SPP __LC_CMF_HPP # set host id
10841089
lg %r14,__LC_THREAD_INFO # pointer thread_info struct
10851090
sie_exit:
1091+
lctlg %c1,%c1,__LC_USER_ASCE # load primary asce
10861092
ni __TI_flags+6(%r14),255-(_TIF_SIE>>8)
10871093
lg %r14,__SF_EMPTY+8(%r15) # load guest register save area
10881094
stmg %r0,%r13,0(%r14) # save guest gprs 0-13

arch/s390/kvm/kvm-s390.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ int kvm_dev_ioctl_check_extension(long ext)
123123

124124
switch (ext) {
125125
case KVM_CAP_S390_PSW:
126+
case KVM_CAP_S390_GMAP:
126127
r = 1;
127128
break;
128129
default:
@@ -263,10 +264,12 @@ void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
263264
vcpu->arch.guest_fpregs.fpc &= FPC_VALID_MASK;
264265
restore_fp_regs(&vcpu->arch.guest_fpregs);
265266
restore_access_regs(vcpu->arch.guest_acrs);
267+
gmap_enable(vcpu->arch.gmap);
266268
}
267269

268270
void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu)
269271
{
272+
gmap_disable(vcpu->arch.gmap);
270273
save_fp_regs(&vcpu->arch.guest_fpregs);
271274
save_access_regs(vcpu->arch.guest_acrs);
272275
restore_fp_regs(&vcpu->arch.host_fpregs);
@@ -461,7 +464,6 @@ static void __vcpu_run(struct kvm_vcpu *vcpu)
461464
local_irq_disable();
462465
kvm_guest_enter();
463466
local_irq_enable();
464-
gmap_enable(vcpu->arch.gmap);
465467
VCPU_EVENT(vcpu, 6, "entering sie flags %x",
466468
atomic_read(&vcpu->arch.sie_block->cpuflags));
467469
if (sie64a(vcpu->arch.sie_block, vcpu->arch.guest_gprs)) {
@@ -470,7 +472,6 @@ static void __vcpu_run(struct kvm_vcpu *vcpu)
470472
}
471473
VCPU_EVENT(vcpu, 6, "exit sie icptcode %d",
472474
vcpu->arch.sie_block->icptcode);
473-
gmap_disable(vcpu->arch.gmap);
474475
local_irq_disable();
475476
kvm_guest_exit();
476477
local_irq_enable();

arch/s390/mm/pgtable.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ struct gmap *gmap_alloc(struct mm_struct *mm)
160160
table = (unsigned long *) page_to_phys(page);
161161
crst_table_init(table, _REGION1_ENTRY_EMPTY);
162162
gmap->table = table;
163+
gmap->asce = _ASCE_TYPE_REGION1 | _ASCE_TABLE_LENGTH |
164+
_ASCE_USER_BITS | __pa(table);
163165
list_add(&gmap->list, &mm->context.gmap_list);
164166
return gmap;
165167

@@ -240,10 +242,6 @@ EXPORT_SYMBOL_GPL(gmap_free);
240242
*/
241243
void gmap_enable(struct gmap *gmap)
242244
{
243-
/* Load primary space page table origin. */
244-
S390_lowcore.user_asce = _ASCE_TYPE_REGION1 | _ASCE_TABLE_LENGTH |
245-
_ASCE_USER_BITS | __pa(gmap->table);
246-
asm volatile("lctlg 1,1,%0\n" : : "m" (S390_lowcore.user_asce) );
247245
S390_lowcore.gmap = (unsigned long) gmap;
248246
}
249247
EXPORT_SYMBOL_GPL(gmap_enable);
@@ -254,10 +252,6 @@ EXPORT_SYMBOL_GPL(gmap_enable);
254252
*/
255253
void gmap_disable(struct gmap *gmap)
256254
{
257-
/* Load primary space page table origin. */
258-
S390_lowcore.user_asce =
259-
gmap->mm->context.asce_bits | __pa(gmap->mm->pgd);
260-
asm volatile("lctlg 1,1,%0\n" : : "m" (S390_lowcore.user_asce) );
261255
S390_lowcore.gmap = 0UL;
262256
}
263257
EXPORT_SYMBOL_GPL(gmap_disable);

include/linux/kvm.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,7 @@ struct kvm_ppc_pvinfo {
553553
#define KVM_CAP_SPAPR_TCE 63
554554
#define KVM_CAP_PPC_SMT 64
555555
#define KVM_CAP_PPC_RMA 65
556+
#define KVM_CAP_S390_GMAP 71
556557

557558
#ifdef KVM_CAP_IRQ_ROUTING
558559

0 commit comments

Comments
 (0)