[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH v8 06/16] microcode: introduce a global cache of ucode patch


  • To: Chao Gao <chao.gao@xxxxxxxxx>
  • From: Jan Beulich <JBeulich@xxxxxxxx>
  • Date: Fri, 2 Aug 2019 14:46:58 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1;spf=pass smtp.mailfrom=suse.com;dmarc=pass action=none header.from=suse.com;dkim=pass header.d=suse.com;arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=NVoMFbuwCSamqEP2kwaablSdQNddzJBauAG2Tw7fE8I=; b=Rd+n1jBEP/nyCL4PE2F2+ReHzfevrO3eyqpdwxfCWWGcBe4K2zae2cBtR4htx+QNBauqPrE5PEZCxltGY/Wz6Gj5ZEgj0c4ky1ivkkEInGnQ0LMXebl9baDCpFOmHzPyJ7aPlwMtFdCWRXY+/ouaKz+NNUtqF9wEoBWb4P3xN9YcaD4sXskB8BhDRaENCfkBXPlEcRvJXQSYNtisyekCMh7WM5FSu0PMeLr+2yOwLrL011XDbXvWmOcYDbBabuntkSDQAHdcMdEoc4h3mfNMyoEtnqj7weRXE9KvxjeXTvI1muUlInnU/lCRoscDrCA2KjzmgSIiu3GRbn8l4JPZkQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jF6p20JpDEKnvRv2MKQ3RNqeGSajW379MY3HWGH2LJ+fAUzz8tL82Y2cWXLGJy6Gu57NP9U4wafIOU4kCHIHYcM+Rub3vHF/J7Gd3+VpFZ2y7xm1I/Gyo5Bi1NnCcVgYHl43x4xbWDDuHysTnreLNgeqistnvW7vjWbmMKxr7beJUNRKydi1h5iiEsyOEKmfUNtysAF60CjOrwkgDjoItJSoWuJYZC+77Uac+BeOK/v3Aja72L35ft9zhfuqPHdCFkTQxEGIC532GiLdJu9sYzIrxQBcr/Ttc99lxWq/9gH5wOvleQ/JoIfvyNpgIa+QZ5g1di9VXq7Cn8O8NJ91fg==
  • Authentication-results: spf=none (sender IP is ) smtp.mailfrom=JBeulich@xxxxxxxx;
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Ashok Raj <ashok.raj@xxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Delivery-date: Fri, 02 Aug 2019 14:50:31 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHVSFKbg6V+T8KOdE+RBvqghdKkCKbn8Z0A
  • Thread-topic: [PATCH v8 06/16] microcode: introduce a global cache of ucode patch

On 01.08.2019 12:22, Chao Gao wrote:
> +bool microcode_update_cache(struct microcode_patch *patch)
> +{
> +
> +    ASSERT(spin_is_locked(&microcode_mutex));
> +
> +    if ( !microcode_cache )
> +        microcode_cache = patch;
> +    else if ( microcode_ops->compare_patch(patch, microcode_cache) ==
> +                  NEW_UCODE )

Indentation is wrong here.

> +static struct microcode_patch *alloc_microcode_patch(
> +    const struct microcode_amd *mc_amd)
> +{
> +    struct microcode_patch *microcode_patch = xmalloc(struct 
> microcode_patch);
> +    struct microcode_amd *cache = xmalloc(struct microcode_amd);
> +    void *mpb = xmalloc_bytes(mc_amd->mpb_size);
> +    struct equiv_cpu_entry *equiv_cpu_table =
> +                                xmalloc_bytes(mc_amd->equiv_cpu_table_size);
> +
> +    if ( !microcode_patch || !cache || !mpb || !equiv_cpu_table )
> +    {
> +        xfree(microcode_patch);
> +        xfree(cache);
> +        xfree(mpb);
> +        xfree(equiv_cpu_table);
> +        return ERR_PTR(-ENOMEM);
> +    }
> +
> +    memcpy(mpb, mc_amd->mpb, mc_amd->mpb_size);
> +    cache->mpb = mpb;
> +    cache->mpb_size = mc_amd->mpb_size;
> +    memcpy(equiv_cpu_table, mc_amd->equiv_cpu_table,
> +           mc_amd->equiv_cpu_table_size);
> +    cache->equiv_cpu_table = equiv_cpu_table;
> +    cache->equiv_cpu_table_size = mc_amd->equiv_cpu_table_size;
> +    microcode_patch->mc_amd = cache;
> +
> +    return microcode_patch;
> +}

Why is it that everything needs to be copied here, rather than
simply shuffling one (or a few) pointer(s)? Can't the caller
simply install the argument it passes here as the new cache blob?

> +static enum microcode_match_result compare_patch(
> +    const struct microcode_patch *new, const struct microcode_patch *old)
> +{
> +    const struct microcode_header_intel *old_header = &old->mc_intel->hdr;
> +
> +    return microcode_update_match(&new->mc_intel->hdr, old_header->sig,
> +                                  old_header->pf, old_header->rev);

So this is exactly what I said on the earlier patch the function
cannot be used for. The way "pf" works precludes this, as said in
reply to an earlier version, and no-one corrected me (i.e. I'm in
no way excluding I'm misunderstanding something here).

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

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.