Skip to content

Commit 8949170

Browse files
committed
Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm
Pull more kvm updates from Paolo Bonzini: "Mostly the PPC part of the release, but also switching to Arnd's fix for the hyperv config issue and a typo fix. Main PPC changes: - reimplement the MMIO instruction emulation - transactional memory support for PR KVM - improve radix page table handling" * tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm: (63 commits) KVM: x86: VMX: redo fix for link error without CONFIG_HYPERV KVM: x86: fix typo at kvm_arch_hardware_setup comment KVM: PPC: Book3S PR: Fix failure status setting in tabort. emulation KVM: PPC: Book3S PR: Enable use on POWER9 bare-metal hosts in HPT mode KVM: PPC: Book3S PR: Don't let PAPR guest set MSR hypervisor bit KVM: PPC: Book3S PR: Fix failure status setting in treclaim. emulation KVM: PPC: Book3S PR: Fix MSR setting when delivering interrupts KVM: PPC: Book3S PR: Handle additional interrupt types KVM: PPC: Book3S PR: Enable kvmppc_get/set_one_reg_pr() for HTM registers KVM: PPC: Book3S: Remove load/put vcpu for KVM_GET_REGS/KVM_SET_REGS KVM: PPC: Remove load/put vcpu for KVM_GET/SET_ONE_REG ioctl KVM: PPC: Move vcpu_load/vcpu_put down to each ioctl case in kvm_arch_vcpu_ioctl KVM: PPC: Book3S PR: Enable HTM for PR KVM for KVM_CHECK_EXTENSION ioctl KVM: PPC: Book3S PR: Support TAR handling for PR KVM HTM KVM: PPC: Book3S PR: Add guard code to prevent returning to guest with PR=0 and Transactional state KVM: PPC: Book3S PR: Add emulation for tabort. in privileged state KVM: PPC: Book3S PR: Add emulation for trechkpt. KVM: PPC: Book3S PR: Add emulation for treclaim. KVM: PPC: Book3S PR: Restore NV regs after emulating mfspr from TM SPRs KVM: PPC: Book3S PR: Always fail transactions in guest privileged state ...
2 parents 2f3f056 + 1f008e1 commit 8949170

40 files changed

+2313
-1233
lines changed

arch/powerpc/include/asm/asm-prototypes.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,13 @@ unsigned long prepare_ftrace_return(unsigned long parent, unsigned long ip);
134134
void pnv_power9_force_smt4_catch(void);
135135
void pnv_power9_force_smt4_release(void);
136136

137+
/* Transaction memory related */
137138
void tm_enable(void);
138139
void tm_disable(void);
139140
void tm_abort(uint8_t cause);
141+
142+
struct kvm_vcpu;
143+
void _kvmppc_restore_tm_pr(struct kvm_vcpu *vcpu, u64 guest_msr);
144+
void _kvmppc_save_tm_pr(struct kvm_vcpu *vcpu, u64 guest_msr);
145+
140146
#endif /* _ASM_POWERPC_ASM_PROTOTYPES_H */

arch/powerpc/include/asm/kvm_book3s.h

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ struct kvmppc_vcore {
104104
ulong vtb; /* virtual timebase */
105105
ulong conferring_threads;
106106
unsigned int halt_poll_ns;
107+
atomic_t online_count;
107108
};
108109

109110
struct kvmppc_vcpu_book3s {
@@ -209,6 +210,7 @@ extern void kvmppc_book3s_queue_irqprio(struct kvm_vcpu *vcpu, unsigned int vec)
209210
extern void kvmppc_book3s_dequeue_irqprio(struct kvm_vcpu *vcpu,
210211
unsigned int vec);
211212
extern void kvmppc_inject_interrupt(struct kvm_vcpu *vcpu, int vec, u64 flags);
213+
extern void kvmppc_trigger_fac_interrupt(struct kvm_vcpu *vcpu, ulong fac);
212214
extern void kvmppc_set_bat(struct kvm_vcpu *vcpu, struct kvmppc_bat *bat,
213215
bool upper, u32 val);
214216
extern void kvmppc_giveup_ext(struct kvm_vcpu *vcpu, ulong msr);
@@ -256,6 +258,21 @@ extern int kvmppc_hcall_impl_pr(unsigned long cmd);
256258
extern int kvmppc_hcall_impl_hv_realmode(unsigned long cmd);
257259
extern void kvmppc_copy_to_svcpu(struct kvm_vcpu *vcpu);
258260
extern void kvmppc_copy_from_svcpu(struct kvm_vcpu *vcpu);
261+
262+
#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
263+
void kvmppc_save_tm_pr(struct kvm_vcpu *vcpu);
264+
void kvmppc_restore_tm_pr(struct kvm_vcpu *vcpu);
265+
void kvmppc_save_tm_sprs(struct kvm_vcpu *vcpu);
266+
void kvmppc_restore_tm_sprs(struct kvm_vcpu *vcpu);
267+
#else
268+
static inline void kvmppc_save_tm_pr(struct kvm_vcpu *vcpu) {}
269+
static inline void kvmppc_restore_tm_pr(struct kvm_vcpu *vcpu) {}
270+
static inline void kvmppc_save_tm_sprs(struct kvm_vcpu *vcpu) {}
271+
static inline void kvmppc_restore_tm_sprs(struct kvm_vcpu *vcpu) {}
272+
#endif
273+
274+
void kvmppc_giveup_fac(struct kvm_vcpu *vcpu, ulong fac);
275+
259276
extern int kvm_irq_bypass;
260277

261278
static inline struct kvmppc_vcpu_book3s *to_book3s(struct kvm_vcpu *vcpu)
@@ -274,12 +291,12 @@ static inline struct kvmppc_vcpu_book3s *to_book3s(struct kvm_vcpu *vcpu)
274291

275292
static inline void kvmppc_set_gpr(struct kvm_vcpu *vcpu, int num, ulong val)
276293
{
277-
vcpu->arch.gpr[num] = val;
294+
vcpu->arch.regs.gpr[num] = val;
278295
}
279296

280297
static inline ulong kvmppc_get_gpr(struct kvm_vcpu *vcpu, int num)
281298
{
282-
return vcpu->arch.gpr[num];
299+
return vcpu->arch.regs.gpr[num];
283300
}
284301

285302
static inline void kvmppc_set_cr(struct kvm_vcpu *vcpu, u32 val)
@@ -294,42 +311,42 @@ static inline u32 kvmppc_get_cr(struct kvm_vcpu *vcpu)
294311

295312
static inline void kvmppc_set_xer(struct kvm_vcpu *vcpu, ulong val)
296313
{
297-
vcpu->arch.xer = val;
314+
vcpu->arch.regs.xer = val;
298315
}
299316

300317
static inline ulong kvmppc_get_xer(struct kvm_vcpu *vcpu)
301318
{
302-
return vcpu->arch.xer;
319+
return vcpu->arch.regs.xer;
303320
}
304321

305322
static inline void kvmppc_set_ctr(struct kvm_vcpu *vcpu, ulong val)
306323
{
307-
vcpu->arch.ctr = val;
324+
vcpu->arch.regs.ctr = val;
308325
}
309326

310327
static inline ulong kvmppc_get_ctr(struct kvm_vcpu *vcpu)
311328
{
312-
return vcpu->arch.ctr;
329+
return vcpu->arch.regs.ctr;
313330
}
314331

315332
static inline void kvmppc_set_lr(struct kvm_vcpu *vcpu, ulong val)
316333
{
317-
vcpu->arch.lr = val;
334+
vcpu->arch.regs.link = val;
318335
}
319336

320337
static inline ulong kvmppc_get_lr(struct kvm_vcpu *vcpu)
321338
{
322-
return vcpu->arch.lr;
339+
return vcpu->arch.regs.link;
323340
}
324341

325342
static inline void kvmppc_set_pc(struct kvm_vcpu *vcpu, ulong val)
326343
{
327-
vcpu->arch.pc = val;
344+
vcpu->arch.regs.nip = val;
328345
}
329346

330347
static inline ulong kvmppc_get_pc(struct kvm_vcpu *vcpu)
331348
{
332-
return vcpu->arch.pc;
349+
return vcpu->arch.regs.nip;
333350
}
334351

335352
static inline u64 kvmppc_get_msr(struct kvm_vcpu *vcpu);

arch/powerpc/include/asm/kvm_book3s_64.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -483,15 +483,15 @@ static inline u64 sanitize_msr(u64 msr)
483483
static inline void copy_from_checkpoint(struct kvm_vcpu *vcpu)
484484
{
485485
vcpu->arch.cr = vcpu->arch.cr_tm;
486-
vcpu->arch.xer = vcpu->arch.xer_tm;
487-
vcpu->arch.lr = vcpu->arch.lr_tm;
488-
vcpu->arch.ctr = vcpu->arch.ctr_tm;
486+
vcpu->arch.regs.xer = vcpu->arch.xer_tm;
487+
vcpu->arch.regs.link = vcpu->arch.lr_tm;
488+
vcpu->arch.regs.ctr = vcpu->arch.ctr_tm;
489489
vcpu->arch.amr = vcpu->arch.amr_tm;
490490
vcpu->arch.ppr = vcpu->arch.ppr_tm;
491491
vcpu->arch.dscr = vcpu->arch.dscr_tm;
492492
vcpu->arch.tar = vcpu->arch.tar_tm;
493-
memcpy(vcpu->arch.gpr, vcpu->arch.gpr_tm,
494-
sizeof(vcpu->arch.gpr));
493+
memcpy(vcpu->arch.regs.gpr, vcpu->arch.gpr_tm,
494+
sizeof(vcpu->arch.regs.gpr));
495495
vcpu->arch.fp = vcpu->arch.fp_tm;
496496
vcpu->arch.vr = vcpu->arch.vr_tm;
497497
vcpu->arch.vrsave = vcpu->arch.vrsave_tm;
@@ -500,15 +500,15 @@ static inline void copy_from_checkpoint(struct kvm_vcpu *vcpu)
500500
static inline void copy_to_checkpoint(struct kvm_vcpu *vcpu)
501501
{
502502
vcpu->arch.cr_tm = vcpu->arch.cr;
503-
vcpu->arch.xer_tm = vcpu->arch.xer;
504-
vcpu->arch.lr_tm = vcpu->arch.lr;
505-
vcpu->arch.ctr_tm = vcpu->arch.ctr;
503+
vcpu->arch.xer_tm = vcpu->arch.regs.xer;
504+
vcpu->arch.lr_tm = vcpu->arch.regs.link;
505+
vcpu->arch.ctr_tm = vcpu->arch.regs.ctr;
506506
vcpu->arch.amr_tm = vcpu->arch.amr;
507507
vcpu->arch.ppr_tm = vcpu->arch.ppr;
508508
vcpu->arch.dscr_tm = vcpu->arch.dscr;
509509
vcpu->arch.tar_tm = vcpu->arch.tar;
510-
memcpy(vcpu->arch.gpr_tm, vcpu->arch.gpr,
511-
sizeof(vcpu->arch.gpr));
510+
memcpy(vcpu->arch.gpr_tm, vcpu->arch.regs.gpr,
511+
sizeof(vcpu->arch.regs.gpr));
512512
vcpu->arch.fp_tm = vcpu->arch.fp;
513513
vcpu->arch.vr_tm = vcpu->arch.vr;
514514
vcpu->arch.vrsave_tm = vcpu->arch.vrsave;

arch/powerpc/include/asm/kvm_booke.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@
3636

3737
static inline void kvmppc_set_gpr(struct kvm_vcpu *vcpu, int num, ulong val)
3838
{
39-
vcpu->arch.gpr[num] = val;
39+
vcpu->arch.regs.gpr[num] = val;
4040
}
4141

4242
static inline ulong kvmppc_get_gpr(struct kvm_vcpu *vcpu, int num)
4343
{
44-
return vcpu->arch.gpr[num];
44+
return vcpu->arch.regs.gpr[num];
4545
}
4646

4747
static inline void kvmppc_set_cr(struct kvm_vcpu *vcpu, u32 val)
@@ -56,12 +56,12 @@ static inline u32 kvmppc_get_cr(struct kvm_vcpu *vcpu)
5656

5757
static inline void kvmppc_set_xer(struct kvm_vcpu *vcpu, ulong val)
5858
{
59-
vcpu->arch.xer = val;
59+
vcpu->arch.regs.xer = val;
6060
}
6161

6262
static inline ulong kvmppc_get_xer(struct kvm_vcpu *vcpu)
6363
{
64-
return vcpu->arch.xer;
64+
return vcpu->arch.regs.xer;
6565
}
6666

6767
static inline bool kvmppc_need_byteswap(struct kvm_vcpu *vcpu)
@@ -72,32 +72,32 @@ static inline bool kvmppc_need_byteswap(struct kvm_vcpu *vcpu)
7272

7373
static inline void kvmppc_set_ctr(struct kvm_vcpu *vcpu, ulong val)
7474
{
75-
vcpu->arch.ctr = val;
75+
vcpu->arch.regs.ctr = val;
7676
}
7777

7878
static inline ulong kvmppc_get_ctr(struct kvm_vcpu *vcpu)
7979
{
80-
return vcpu->arch.ctr;
80+
return vcpu->arch.regs.ctr;
8181
}
8282

8383
static inline void kvmppc_set_lr(struct kvm_vcpu *vcpu, ulong val)
8484
{
85-
vcpu->arch.lr = val;
85+
vcpu->arch.regs.link = val;
8686
}
8787

8888
static inline ulong kvmppc_get_lr(struct kvm_vcpu *vcpu)
8989
{
90-
return vcpu->arch.lr;
90+
return vcpu->arch.regs.link;
9191
}
9292

9393
static inline void kvmppc_set_pc(struct kvm_vcpu *vcpu, ulong val)
9494
{
95-
vcpu->arch.pc = val;
95+
vcpu->arch.regs.nip = val;
9696
}
9797

9898
static inline ulong kvmppc_get_pc(struct kvm_vcpu *vcpu)
9999
{
100-
return vcpu->arch.pc;
100+
return vcpu->arch.regs.nip;
101101
}
102102

103103
static inline ulong kvmppc_get_fault_dar(struct kvm_vcpu *vcpu)

arch/powerpc/include/asm/kvm_host.h

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,6 @@ struct kvm_arch {
269269
unsigned long host_lpcr;
270270
unsigned long sdr1;
271271
unsigned long host_sdr1;
272-
int tlbie_lock;
273272
unsigned long lpcr;
274273
unsigned long vrma_slb_v;
275274
int mmu_ready;
@@ -454,6 +453,12 @@ struct mmio_hpte_cache {
454453
#define KVMPPC_VSX_COPY_WORD 1
455454
#define KVMPPC_VSX_COPY_DWORD 2
456455
#define KVMPPC_VSX_COPY_DWORD_LOAD_DUMP 3
456+
#define KVMPPC_VSX_COPY_WORD_LOAD_DUMP 4
457+
458+
#define KVMPPC_VMX_COPY_BYTE 8
459+
#define KVMPPC_VMX_COPY_HWORD 9
460+
#define KVMPPC_VMX_COPY_WORD 10
461+
#define KVMPPC_VMX_COPY_DWORD 11
457462

458463
struct openpic;
459464

@@ -486,7 +491,7 @@ struct kvm_vcpu_arch {
486491
struct kvmppc_book3s_shadow_vcpu *shadow_vcpu;
487492
#endif
488493

489-
ulong gpr[32];
494+
struct pt_regs regs;
490495

491496
struct thread_fp_state fp;
492497

@@ -521,14 +526,10 @@ struct kvm_vcpu_arch {
521526
u32 qpr[32];
522527
#endif
523528

524-
ulong pc;
525-
ulong ctr;
526-
ulong lr;
527529
#ifdef CONFIG_PPC_BOOK3S
528530
ulong tar;
529531
#endif
530532

531-
ulong xer;
532533
u32 cr;
533534

534535
#ifdef CONFIG_PPC_BOOK3S
@@ -626,7 +627,6 @@ struct kvm_vcpu_arch {
626627

627628
struct thread_vr_state vr_tm;
628629
u32 vrsave_tm; /* also USPRG0 */
629-
630630
#endif
631631

632632
#ifdef CONFIG_KVM_EXIT_TIMING
@@ -681,16 +681,17 @@ struct kvm_vcpu_arch {
681681
* Number of simulations for vsx.
682682
* If we use 2*8bytes to simulate 1*16bytes,
683683
* then the number should be 2 and
684-
* mmio_vsx_copy_type=KVMPPC_VSX_COPY_DWORD.
684+
* mmio_copy_type=KVMPPC_VSX_COPY_DWORD.
685685
* If we use 4*4bytes to simulate 1*16bytes,
686686
* the number should be 4 and
687687
* mmio_vsx_copy_type=KVMPPC_VSX_COPY_WORD.
688688
*/
689689
u8 mmio_vsx_copy_nums;
690690
u8 mmio_vsx_offset;
691-
u8 mmio_vsx_copy_type;
692691
u8 mmio_vsx_tx_sx_enabled;
693692
u8 mmio_vmx_copy_nums;
693+
u8 mmio_vmx_offset;
694+
u8 mmio_copy_type;
694695
u8 osi_needed;
695696
u8 osi_enabled;
696697
u8 papr_enabled;
@@ -772,6 +773,8 @@ struct kvm_vcpu_arch {
772773
u64 busy_preempt;
773774

774775
u32 emul_inst;
776+
777+
u32 online;
775778
#endif
776779

777780
#ifdef CONFIG_KVM_BOOK3S_HV_EXIT_TIMING

arch/powerpc/include/asm/kvm_ppc.h

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ enum emulation_result {
5252
EMULATE_EXIT_USER, /* emulation requires exit to user-space */
5353
};
5454

55-
enum instruction_type {
55+
enum instruction_fetch_type {
5656
INST_GENERIC,
5757
INST_SC, /* system call */
5858
};
@@ -81,10 +81,10 @@ extern int kvmppc_handle_loads(struct kvm_run *run, struct kvm_vcpu *vcpu,
8181
extern int kvmppc_handle_vsx_load(struct kvm_run *run, struct kvm_vcpu *vcpu,
8282
unsigned int rt, unsigned int bytes,
8383
int is_default_endian, int mmio_sign_extend);
84-
extern int kvmppc_handle_load128_by2x64(struct kvm_run *run,
85-
struct kvm_vcpu *vcpu, unsigned int rt, int is_default_endian);
86-
extern int kvmppc_handle_store128_by2x64(struct kvm_run *run,
87-
struct kvm_vcpu *vcpu, unsigned int rs, int is_default_endian);
84+
extern int kvmppc_handle_vmx_load(struct kvm_run *run, struct kvm_vcpu *vcpu,
85+
unsigned int rt, unsigned int bytes, int is_default_endian);
86+
extern int kvmppc_handle_vmx_store(struct kvm_run *run, struct kvm_vcpu *vcpu,
87+
unsigned int rs, unsigned int bytes, int is_default_endian);
8888
extern int kvmppc_handle_store(struct kvm_run *run, struct kvm_vcpu *vcpu,
8989
u64 val, unsigned int bytes,
9090
int is_default_endian);
@@ -93,7 +93,7 @@ extern int kvmppc_handle_vsx_store(struct kvm_run *run, struct kvm_vcpu *vcpu,
9393
int is_default_endian);
9494

9595
extern int kvmppc_load_last_inst(struct kvm_vcpu *vcpu,
96-
enum instruction_type type, u32 *inst);
96+
enum instruction_fetch_type type, u32 *inst);
9797

9898
extern int kvmppc_ld(struct kvm_vcpu *vcpu, ulong *eaddr, int size, void *ptr,
9999
bool data);
@@ -265,6 +265,8 @@ union kvmppc_one_reg {
265265
vector128 vval;
266266
u64 vsxval[2];
267267
u32 vsx32val[4];
268+
u16 vsx16val[8];
269+
u8 vsx8val[16];
268270
struct {
269271
u64 addr;
270272
u64 length;
@@ -324,13 +326,14 @@ struct kvmppc_ops {
324326
int (*get_rmmu_info)(struct kvm *kvm, struct kvm_ppc_rmmu_info *info);
325327
int (*set_smt_mode)(struct kvm *kvm, unsigned long mode,
326328
unsigned long flags);
329+
void (*giveup_ext)(struct kvm_vcpu *vcpu, ulong msr);
327330
};
328331

329332
extern struct kvmppc_ops *kvmppc_hv_ops;
330333
extern struct kvmppc_ops *kvmppc_pr_ops;
331334

332335
static inline int kvmppc_get_last_inst(struct kvm_vcpu *vcpu,
333-
enum instruction_type type, u32 *inst)
336+
enum instruction_fetch_type type, u32 *inst)
334337
{
335338
int ret = EMULATE_DONE;
336339
u32 fetched_inst;

arch/powerpc/include/asm/reg.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,7 @@
385385
#define SPRN_PSSCR 0x357 /* Processor Stop Status and Control Register (ISA 3.0) */
386386
#define SPRN_PSSCR_PR 0x337 /* PSSCR ISA 3.0, privileged mode access */
387387
#define SPRN_PMCR 0x374 /* Power Management Control Register */
388+
#define SPRN_RWMR 0x375 /* Region-Weighting Mode Register */
388389

389390
/* HFSCR and FSCR bit numbers are the same */
390391
#define FSCR_SCV_LG 12 /* Enable System Call Vectored */

arch/powerpc/include/uapi/asm/kvm.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -633,6 +633,7 @@ struct kvm_ppc_cpu_char {
633633
#define KVM_REG_PPC_PSSCR (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xbd)
634634

635635
#define KVM_REG_PPC_DEC_EXPIRY (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xbe)
636+
#define KVM_REG_PPC_ONLINE (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0xbf)
636637

637638
/* Transactional Memory checkpointed state:
638639
* This is all GPRs, all VSX regs and a subset of SPRs

0 commit comments

Comments
 (0)