On 08/06/18 10:59, Roger Pau Monne wrote:
> @@ -1014,6 +1034,30 @@ static int vcpu_hvm(struct xc_dom_image *dom)
>      if ( dom->start_info_seg.pfn )
>          bsp_ctx.cpu.rbx = dom->start_info_seg.pfn << PAGE_SHIFT;
>  
> +    /* Set the MTRR. */
> +    bsp_ctx.mtrr_d.typecode = HVM_SAVE_CODE(MTRR);
> +    bsp_ctx.mtrr_d.instance = 0;
> +    bsp_ctx.mtrr_d.length = HVM_SAVE_LENGTH(MTRR);
> +
> +    mtrr_record = hvm_get_save_record(full_ctx, HVM_SAVE_CODE(MTRR), 0);
> +    if ( !mtrr_record )
> +    {
> +        xc_dom_panic(dom->xch, XC_INTERNAL_ERROR,
> +                     "%s: unable to get MTRR save record", __func__);
> +        goto out;
> +    }
> +
> +    memcpy(&bsp_ctx.mtrr, mtrr_record, sizeof(bsp_ctx.mtrr));
> +
> +    /* TODO: maybe this should be a firmware option instead? */
> +    if ( !dom->device_model )
> +        /*
> +         * Enable MTRR, set default type to WB.
> +         * TODO: add MMIO areas as UC when passthrough is supported.
> +         */
> +        bsp_ctx.mtrr.msr_mtrr_def_type = MTRR_TYPE_WRBACK |
> +                                         MTRR_DEF_TYPE_ENABLE;

This is buggy.  MTRRs are per-vcpu and expected to match.  This only
works by chance in the HVM case because all settings are still 0 at this
point.

Currently, booting a multi-vcpu PVH guest (the shim, specifically) yields:

(d6) (XEN) mtrr: your CPUs had inconsistent MTRRdefType settings
(d6) (XEN) mtrr: probably your BIOS does not setup all CPUs.
(d6) (XEN) mtrr: corrected configuration.
(d6) (XEN) MTRR default type: write-back
(d6) (XEN) MTRR fixed ranges disabled:
(d6) (XEN)   00000-fffff uncachable
(d6) (XEN) MTRR variable ranges enabled:
(d6) (XEN)   0 disabled
(d6) (XEN)   1 disabled
(d6) (XEN)   2 disabled
(d6) (XEN)   3 disabled
(d6) (XEN)   4 disabled
(d6) (XEN)   5 disabled
(d6) (XEN)   6 disabled
(d6) (XEN)   7 disabled

~Andrew

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Reply via email to