Skip to content

Commit 8b51fa4

Browse files
ozbenhstewartsmith
authored andcommitted
xive: Don't reconfigure and enable queues and VPs in exploitation
When the OS calls opal_xive_reset() to switch to exploitation mode, we shouldn't re-enable all the queues and VPs. The OS will do it. Otherwise, we miss the enable/disable transition, thus failing to re-initialize the queue count and generation. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
1 parent 2830a14 commit 8b51fa4

File tree

1 file changed

+56
-31
lines changed

1 file changed

+56
-31
lines changed

hw/xive.c

Lines changed: 56 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -802,9 +802,9 @@ static void xive_init_default_vp(struct xive_vp *vp,
802802
vp->w0 = VP_W0_VALID;
803803
}
804804

805-
static void xive_init_default_eq(uint32_t vp_blk, uint32_t vp_idx,
806-
struct xive_eq *eq, void *backing_page,
807-
uint8_t prio)
805+
static void xive_init_emu_eq(uint32_t vp_blk, uint32_t vp_idx,
806+
struct xive_eq *eq, void *backing_page,
807+
uint8_t prio)
808808
{
809809
memset(eq, 0, sizeof(struct xive_eq));
810810

@@ -2810,12 +2810,9 @@ void xive_cpu_callin(struct cpu_thread *cpu)
28102810
out_8(xs->tm_ring1 + TM_QW3_HV_PHYS + TM_WORD2, 0x80);
28112811

28122812
xive_cpu_dbg(cpu, "Initialized interrupt management area\n");
2813-
2814-
/* Now unmask the IPI */
2815-
xive_ipi_init(x, cpu);
28162813
}
28172814

2818-
static void xive_init_cpu_defaults(struct xive_cpu_state *xs)
2815+
static void xive_setup_hw_for_emu(struct xive_cpu_state *xs)
28192816
{
28202817
struct xive_eq eq;
28212818
struct xive_vp vp;
@@ -2835,8 +2832,8 @@ static void xive_init_cpu_defaults(struct xive_cpu_state *xs)
28352832
assert(x_eq);
28362833

28372834
/* Initialize the structure */
2838-
xive_init_default_eq(xs->vp_blk, xs->vp_idx, &eq,
2839-
xs->eq_page, XIVE_EMULATION_PRIO);
2835+
xive_init_emu_eq(xs->vp_blk, xs->vp_idx, &eq,
2836+
xs->eq_page, XIVE_EMULATION_PRIO);
28402837

28412838
/* Use the cache watch to write it out */
28422839
xive_eqc_cache_update(x_eq, xs->eq_blk,
@@ -2886,25 +2883,60 @@ static void xive_provision_cpu(struct xive_cpu_state *xs, struct cpu_thread *c)
28862883
xs->eq_page = p;
28872884
}
28882885

2889-
static void xive_init_xics_emulation(struct xive_cpu_state *xs)
2886+
static void xive_init_cpu_emulation(struct xive_cpu_state *xs,
2887+
struct cpu_thread *cpu)
28902888
{
28912889
struct xive *x;
28922890

2891+
/* Setup HW EQ and VP */
2892+
xive_setup_hw_for_emu(xs);
2893+
2894+
/* Setup and unmask the IPI */
2895+
xive_ipi_init(xs->xive, cpu);
2896+
2897+
/* Initialize remaining state */
28932898
xs->cppr = 0;
28942899
xs->mfrr = 0xff;
2895-
2896-
xs->eqbuf = xive_get_eq_buf(xs->vp_blk, xs->eq_idx + XIVE_EMULATION_PRIO);
2900+
xs->eqbuf = xive_get_eq_buf(xs->vp_blk,
2901+
xs->eq_idx + XIVE_EMULATION_PRIO);
28972902
assert(xs->eqbuf);
28982903

28992904
xs->eqptr = 0;
29002905
xs->eqmsk = (0x10000/4) - 1;
29012906
xs->eqgen = 0;
2902-
29032907
x = xive_from_vc_blk(xs->eq_blk);
29042908
assert(x);
29052909
xs->eqmmio = x->eq_mmio + (xs->eq_idx + XIVE_EMULATION_PRIO) * 0x20000;
29062910
}
29072911

2912+
static void xive_init_cpu_exploitation(struct xive_cpu_state *xs)
2913+
{
2914+
struct xive_vp vp;
2915+
struct xive *x_vp;
2916+
2917+
/* Grab the XIVE where the VP resides. It could be different from
2918+
* the local chip XIVE if not using block group mode
2919+
*/
2920+
x_vp = xive_from_pc_blk(xs->vp_blk);
2921+
assert(x_vp);
2922+
2923+
/* Initialize/enable the VP */
2924+
xive_init_default_vp(&vp, xs->eq_blk, xs->eq_idx);
2925+
2926+
/* Use the cache watch to write it out */
2927+
xive_vpc_cache_update(x_vp, xs->vp_blk, xs->vp_idx,
2928+
0, 8, &vp, false, true);
2929+
2930+
/* Clenaup remaining state */
2931+
xs->cppr = 0;
2932+
xs->mfrr = 0xff;
2933+
xs->eqbuf = NULL;
2934+
xs->eqptr = 0;
2935+
xs->eqmsk = 0;
2936+
xs->eqgen = 0;
2937+
xs->eqmmio = NULL;
2938+
}
2939+
29082940
static void xive_configure_ex_special_bar(struct xive *x, struct cpu_thread *c)
29092941
{
29102942
uint64_t xa, val;
@@ -2915,7 +2947,7 @@ static void xive_configure_ex_special_bar(struct xive *x, struct cpu_thread *c)
29152947
val = (uint64_t)x->tm_base | P9X_EX_NCU_SPEC_BAR_ENABLE;
29162948
if (x->tm_shift == 16)
29172949
val |= P9X_EX_NCU_SPEC_BAR_256K;
2918-
printf("NCU_SPEC_BAR_XA[%08llx]=%016llx\n", xa, val);
2950+
xive_cpu_dbg(c, "NCU_SPEC_BAR_XA[%08llx]=%016llx\n", xa, val);
29192951
rc = xscom_write(c->chip_id, xa, val);
29202952
if (rc) {
29212953
xive_cpu_err(c, "Failed to setup NCU_SPEC_BAR\n");
@@ -2962,11 +2994,8 @@ static void xive_init_cpu(struct cpu_thread *c)
29622994
/* Provision a VP and some EQDs for a physical CPU */
29632995
xive_provision_cpu(xs, c);
29642996

2965-
/* Configure the default EQ/VP */
2966-
xive_init_cpu_defaults(xs);
2967-
29682997
/* Initialize the XICS emulation related fields */
2969-
xive_init_xics_emulation(xs);
2998+
xive_init_cpu_emulation(xs, c);
29702999
}
29713000

29723001
static void xive_init_cpu_properties(struct cpu_thread *cpu)
@@ -3529,7 +3558,8 @@ static int64_t opal_xive_set_queue_info(uint64_t vp, uint32_t prio,
35293558
if (!xive_decode_vp(vp, &vp_blk, &vp_idx, NULL, &group))
35303559
return OPAL_PARAMETER;
35313560

3532-
/* Make a local copy which we will later try to commit using
3561+
/*
3562+
* Make a local copy which we will later try to commit using
35333563
* the cache watch facility
35343564
*/
35353565
eq = *old_eq;
@@ -3747,13 +3777,14 @@ static void xive_reset_one(struct xive *x)
37473777

37483778
/* Reset all allocated EQs and free the user ones */
37493779
bitmap_for_each_one(*x->eq_map, MAX_EQ_COUNT >> 3, i) {
3750-
struct xive_eq eq0 = {0};
3780+
struct xive_eq eq0;
37513781
struct xive_eq *eq;
37523782
int j;
37533783

37543784
if (i == 0)
37553785
continue;
37563786
eq_firmware = false;
3787+
memset(&eq0, 0, sizeof(eq0));
37573788
for (j = 0; j < 8; j++) {
37583789
uint32_t idx = (i << 3) | j;
37593790

@@ -3821,23 +3852,17 @@ static void xive_reset_one(struct xive *x)
38213852
/* The rest must not be called with the lock held */
38223853
unlock(&x->lock);
38233854

3824-
/* Re-configure the CPUs */
3855+
/* Re-configure VPs and emulation */
38253856
for_each_present_cpu(c) {
38263857
struct xive_cpu_state *xs = c->xstate;
38273858

38283859
if (c->chip_id != x->chip_id || !xs)
38293860
continue;
38303861

3831-
/* Setup default VP and EQ */
3832-
xive_init_cpu_defaults(xs);
3833-
3834-
/* Re-Initialize the XICS emulation related fields
3835-
* and re-enable IPI
3836-
*/
3837-
if (xive_mode == XIVE_MODE_EMU) {
3838-
xive_init_xics_emulation(xs);
3839-
xive_ipi_init(x, c);
3840-
}
3862+
if (xive_mode == XIVE_MODE_EMU)
3863+
xive_init_cpu_emulation(xs, c);
3864+
else
3865+
xive_init_cpu_exploitation(xs);
38413866
}
38423867
}
38433868

0 commit comments

Comments
 (0)