Skip to content

Commit fe2a08e

Browse files
sean-jcbonzini
authored andcommitted
KVM: PPC: e500: Rip out "struct tlbe_ref"
Complete the ~13 year journey started by commit 47bf379 ("kvm/ppc/e500: eliminate tlb_refs"), and actually remove "struct tlbe_ref". No functional change intended (verified disassembly of e500_mmu.o and e500_mmu_host.o is identical before and after). Link: https://patch.msgid.link/20260303190339.974325-3-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent 4c01346 commit fe2a08e

2 files changed

Lines changed: 45 additions & 52 deletions

File tree

arch/powerpc/kvm/e500.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,11 @@ enum vcpu_ftr {
3939
/* bits [6-5] MAS2_X1 and MAS2_X0 and [4-0] bits for WIMGE */
4040
#define E500_TLB_MAS2_ATTR (0x7f)
4141

42-
struct tlbe_ref {
42+
struct tlbe_priv {
4343
kvm_pfn_t pfn; /* valid only for TLB0, except briefly */
4444
unsigned int flags; /* E500_TLB_* */
4545
};
4646

47-
struct tlbe_priv {
48-
struct tlbe_ref ref;
49-
};
50-
5147
#ifdef CONFIG_KVM_E500V2
5248
struct vcpu_id_table;
5349
#endif

arch/powerpc/kvm/e500_mmu_host.c

Lines changed: 44 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -189,16 +189,16 @@ void inval_gtlbe_on_host(struct kvmppc_vcpu_e500 *vcpu_e500, int tlbsel,
189189
{
190190
struct kvm_book3e_206_tlb_entry *gtlbe =
191191
get_entry(vcpu_e500, tlbsel, esel);
192-
struct tlbe_ref *ref = &vcpu_e500->gtlb_priv[tlbsel][esel].ref;
192+
struct tlbe_priv *tlbe = &vcpu_e500->gtlb_priv[tlbsel][esel];
193193

194194
/* Don't bother with unmapped entries */
195-
if (!(ref->flags & E500_TLB_VALID)) {
196-
WARN(ref->flags & (E500_TLB_BITMAP | E500_TLB_TLB0),
197-
"%s: flags %x\n", __func__, ref->flags);
195+
if (!(tlbe->flags & E500_TLB_VALID)) {
196+
WARN(tlbe->flags & (E500_TLB_BITMAP | E500_TLB_TLB0),
197+
"%s: flags %x\n", __func__, tlbe->flags);
198198
WARN_ON(tlbsel == 1 && vcpu_e500->g2h_tlb1_map[esel]);
199199
}
200200

201-
if (tlbsel == 1 && ref->flags & E500_TLB_BITMAP) {
201+
if (tlbsel == 1 && tlbe->flags & E500_TLB_BITMAP) {
202202
u64 tmp = vcpu_e500->g2h_tlb1_map[esel];
203203
int hw_tlb_indx;
204204
unsigned long flags;
@@ -216,55 +216,55 @@ void inval_gtlbe_on_host(struct kvmppc_vcpu_e500 *vcpu_e500, int tlbsel,
216216
}
217217
mb();
218218
vcpu_e500->g2h_tlb1_map[esel] = 0;
219-
ref->flags &= ~(E500_TLB_BITMAP | E500_TLB_VALID);
219+
tlbe->flags &= ~(E500_TLB_BITMAP | E500_TLB_VALID);
220220
local_irq_restore(flags);
221221
}
222222

223-
if (tlbsel == 1 && ref->flags & E500_TLB_TLB0) {
223+
if (tlbsel == 1 && tlbe->flags & E500_TLB_TLB0) {
224224
/*
225225
* TLB1 entry is backed by 4k pages. This should happen
226226
* rarely and is not worth optimizing. Invalidate everything.
227227
*/
228228
kvmppc_e500_tlbil_all(vcpu_e500);
229-
ref->flags &= ~(E500_TLB_TLB0 | E500_TLB_VALID);
229+
tlbe->flags &= ~(E500_TLB_TLB0 | E500_TLB_VALID);
230230
}
231231

232232
/*
233233
* If TLB entry is still valid then it's a TLB0 entry, and thus
234234
* backed by at most one host tlbe per shadow pid
235235
*/
236-
if (ref->flags & E500_TLB_VALID)
236+
if (tlbe->flags & E500_TLB_VALID)
237237
kvmppc_e500_tlbil_one(vcpu_e500, gtlbe);
238238

239239
/* Mark the TLB as not backed by the host anymore */
240-
ref->flags = 0;
240+
tlbe->flags = 0;
241241
}
242242

243243
static inline int tlbe_is_writable(struct kvm_book3e_206_tlb_entry *tlbe)
244244
{
245245
return tlbe->mas7_3 & (MAS3_SW|MAS3_UW);
246246
}
247247

248-
static inline void kvmppc_e500_ref_setup(struct tlbe_ref *ref,
249-
struct kvm_book3e_206_tlb_entry *gtlbe,
250-
kvm_pfn_t pfn, unsigned int wimg,
251-
bool writable)
248+
static inline void kvmppc_e500_tlbe_setup(struct tlbe_priv *tlbe,
249+
struct kvm_book3e_206_tlb_entry *gtlbe,
250+
kvm_pfn_t pfn, unsigned int wimg,
251+
bool writable)
252252
{
253-
ref->pfn = pfn;
254-
ref->flags = E500_TLB_VALID;
253+
tlbe->pfn = pfn;
254+
tlbe->flags = E500_TLB_VALID;
255255
if (writable)
256-
ref->flags |= E500_TLB_WRITABLE;
256+
tlbe->flags |= E500_TLB_WRITABLE;
257257

258258
/* Use guest supplied MAS2_G and MAS2_E */
259-
ref->flags |= (gtlbe->mas2 & MAS2_ATTRIB_MASK) | wimg;
259+
tlbe->flags |= (gtlbe->mas2 & MAS2_ATTRIB_MASK) | wimg;
260260
}
261261

262-
static inline void kvmppc_e500_ref_release(struct tlbe_ref *ref)
262+
static inline void kvmppc_e500_tlbe_release(struct tlbe_priv *tlbe)
263263
{
264-
if (ref->flags & E500_TLB_VALID) {
264+
if (tlbe->flags & E500_TLB_VALID) {
265265
/* FIXME: don't log bogus pfn for TLB1 */
266-
trace_kvm_booke206_ref_release(ref->pfn, ref->flags);
267-
ref->flags = 0;
266+
trace_kvm_booke206_ref_release(tlbe->pfn, tlbe->flags);
267+
tlbe->flags = 0;
268268
}
269269
}
270270

@@ -284,11 +284,8 @@ static void clear_tlb_privs(struct kvmppc_vcpu_e500 *vcpu_e500)
284284
int i;
285285

286286
for (tlbsel = 0; tlbsel <= 1; tlbsel++) {
287-
for (i = 0; i < vcpu_e500->gtlb_params[tlbsel].entries; i++) {
288-
struct tlbe_ref *ref =
289-
&vcpu_e500->gtlb_priv[tlbsel][i].ref;
290-
kvmppc_e500_ref_release(ref);
291-
}
287+
for (i = 0; i < vcpu_e500->gtlb_params[tlbsel].entries; i++)
288+
kvmppc_e500_tlbe_release(&vcpu_e500->gtlb_priv[tlbsel][i]);
292289
}
293290
}
294291

@@ -304,26 +301,26 @@ void kvmppc_core_flush_tlb(struct kvm_vcpu *vcpu)
304301
static void kvmppc_e500_setup_stlbe(
305302
struct kvm_vcpu *vcpu,
306303
struct kvm_book3e_206_tlb_entry *gtlbe,
307-
int tsize, struct tlbe_ref *ref, u64 gvaddr,
304+
int tsize, struct tlbe_priv *tlbe, u64 gvaddr,
308305
struct kvm_book3e_206_tlb_entry *stlbe)
309306
{
310-
kvm_pfn_t pfn = ref->pfn;
307+
kvm_pfn_t pfn = tlbe->pfn;
311308
u32 pr = vcpu->arch.shared->msr & MSR_PR;
312-
bool writable = !!(ref->flags & E500_TLB_WRITABLE);
309+
bool writable = !!(tlbe->flags & E500_TLB_WRITABLE);
313310

314-
BUG_ON(!(ref->flags & E500_TLB_VALID));
311+
BUG_ON(!(tlbe->flags & E500_TLB_VALID));
315312

316313
/* Force IPROT=0 for all guest mappings. */
317314
stlbe->mas1 = MAS1_TSIZE(tsize) | get_tlb_sts(gtlbe) | MAS1_VALID;
318-
stlbe->mas2 = (gvaddr & MAS2_EPN) | (ref->flags & E500_TLB_MAS2_ATTR);
315+
stlbe->mas2 = (gvaddr & MAS2_EPN) | (tlbe->flags & E500_TLB_MAS2_ATTR);
319316
stlbe->mas7_3 = ((u64)pfn << PAGE_SHIFT) |
320317
e500_shadow_mas3_attrib(gtlbe->mas7_3, writable, pr);
321318
}
322319

323320
static inline int kvmppc_e500_shadow_map(struct kvmppc_vcpu_e500 *vcpu_e500,
324321
u64 gvaddr, gfn_t gfn, struct kvm_book3e_206_tlb_entry *gtlbe,
325322
int tlbsel, struct kvm_book3e_206_tlb_entry *stlbe,
326-
struct tlbe_ref *ref)
323+
struct tlbe_priv *tlbe)
327324
{
328325
struct kvm_memory_slot *slot;
329326
unsigned int psize;
@@ -455,9 +452,9 @@ static inline int kvmppc_e500_shadow_map(struct kvmppc_vcpu_e500 *vcpu_e500,
455452
}
456453
}
457454

458-
kvmppc_e500_ref_setup(ref, gtlbe, pfn, wimg, writable);
455+
kvmppc_e500_tlbe_setup(tlbe, gtlbe, pfn, wimg, writable);
459456
kvmppc_e500_setup_stlbe(&vcpu_e500->vcpu, gtlbe, tsize,
460-
ref, gvaddr, stlbe);
457+
tlbe, gvaddr, stlbe);
461458
writable = tlbe_is_writable(stlbe);
462459

463460
/* Clear i-cache for new pages */
@@ -474,17 +471,17 @@ static int kvmppc_e500_tlb0_map(struct kvmppc_vcpu_e500 *vcpu_e500, int esel,
474471
struct kvm_book3e_206_tlb_entry *stlbe)
475472
{
476473
struct kvm_book3e_206_tlb_entry *gtlbe;
477-
struct tlbe_ref *ref;
474+
struct tlbe_priv *tlbe;
478475
int stlbsel = 0;
479476
int sesel = 0;
480477
int r;
481478

482479
gtlbe = get_entry(vcpu_e500, 0, esel);
483-
ref = &vcpu_e500->gtlb_priv[0][esel].ref;
480+
tlbe = &vcpu_e500->gtlb_priv[0][esel];
484481

485482
r = kvmppc_e500_shadow_map(vcpu_e500, get_tlb_eaddr(gtlbe),
486483
get_tlb_raddr(gtlbe) >> PAGE_SHIFT,
487-
gtlbe, 0, stlbe, ref);
484+
gtlbe, 0, stlbe, tlbe);
488485
if (r)
489486
return r;
490487

@@ -494,7 +491,7 @@ static int kvmppc_e500_tlb0_map(struct kvmppc_vcpu_e500 *vcpu_e500, int esel,
494491
}
495492

496493
static int kvmppc_e500_tlb1_map_tlb1(struct kvmppc_vcpu_e500 *vcpu_e500,
497-
struct tlbe_ref *ref,
494+
struct tlbe_priv *tlbe,
498495
int esel)
499496
{
500497
unsigned int sesel = vcpu_e500->host_tlb1_nv++;
@@ -507,10 +504,10 @@ static int kvmppc_e500_tlb1_map_tlb1(struct kvmppc_vcpu_e500 *vcpu_e500,
507504
vcpu_e500->g2h_tlb1_map[idx] &= ~(1ULL << sesel);
508505
}
509506

510-
vcpu_e500->gtlb_priv[1][esel].ref.flags |= E500_TLB_BITMAP;
507+
vcpu_e500->gtlb_priv[1][esel].flags |= E500_TLB_BITMAP;
511508
vcpu_e500->g2h_tlb1_map[esel] |= (u64)1 << sesel;
512509
vcpu_e500->h2g_tlb1_rmap[sesel] = esel + 1;
513-
WARN_ON(!(ref->flags & E500_TLB_VALID));
510+
WARN_ON(!(tlbe->flags & E500_TLB_VALID));
514511

515512
return sesel;
516513
}
@@ -522,24 +519,24 @@ static int kvmppc_e500_tlb1_map(struct kvmppc_vcpu_e500 *vcpu_e500,
522519
u64 gvaddr, gfn_t gfn, struct kvm_book3e_206_tlb_entry *gtlbe,
523520
struct kvm_book3e_206_tlb_entry *stlbe, int esel)
524521
{
525-
struct tlbe_ref *ref = &vcpu_e500->gtlb_priv[1][esel].ref;
522+
struct tlbe_priv *tlbe = &vcpu_e500->gtlb_priv[1][esel];
526523
int sesel;
527524
int r;
528525

529526
r = kvmppc_e500_shadow_map(vcpu_e500, gvaddr, gfn, gtlbe, 1, stlbe,
530-
ref);
527+
tlbe);
531528
if (r)
532529
return r;
533530

534531
/* Use TLB0 when we can only map a page with 4k */
535532
if (get_tlb_tsize(stlbe) == BOOK3E_PAGESZ_4K) {
536-
vcpu_e500->gtlb_priv[1][esel].ref.flags |= E500_TLB_TLB0;
533+
vcpu_e500->gtlb_priv[1][esel].flags |= E500_TLB_TLB0;
537534
write_stlbe(vcpu_e500, gtlbe, stlbe, 0, 0);
538535
return 0;
539536
}
540537

541538
/* Otherwise map into TLB1 */
542-
sesel = kvmppc_e500_tlb1_map_tlb1(vcpu_e500, ref, esel);
539+
sesel = kvmppc_e500_tlb1_map_tlb1(vcpu_e500, tlbe, esel);
543540
write_stlbe(vcpu_e500, gtlbe, stlbe, 1, sesel);
544541

545542
return 0;
@@ -561,11 +558,11 @@ void kvmppc_mmu_map(struct kvm_vcpu *vcpu, u64 eaddr, gpa_t gpaddr,
561558
priv = &vcpu_e500->gtlb_priv[tlbsel][esel];
562559

563560
/* Triggers after clear_tlb_privs or on initial mapping */
564-
if (!(priv->ref.flags & E500_TLB_VALID)) {
561+
if (!(priv->flags & E500_TLB_VALID)) {
565562
kvmppc_e500_tlb0_map(vcpu_e500, esel, &stlbe);
566563
} else {
567564
kvmppc_e500_setup_stlbe(vcpu, gtlbe, BOOK3E_PAGESZ_4K,
568-
&priv->ref, eaddr, &stlbe);
565+
priv, eaddr, &stlbe);
569566
write_stlbe(vcpu_e500, gtlbe, &stlbe, 0, 0);
570567
}
571568
break;

0 commit comments

Comments
 (0)