From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752216AbdAROox (ORCPT ); Wed, 18 Jan 2017 09:44:53 -0500 Received: from mail.skyhub.de ([78.46.96.112]:55762 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752097AbdAROov (ORCPT ); Wed, 18 Jan 2017 09:44:51 -0500 Date: Wed, 18 Jan 2017 15:44:46 +0100 From: Borislav Petkov To: Thomas Gleixner Cc: X86 ML , LKML Subject: Re: [PATCH 06/13] x86/microcode/AMD: Rework container parsing Message-ID: <20170118144446.up7kdyfi2hylfuej@pd.tnic> References: <20170117173734.14251-1-bp@alien8.de> <20170117173734.14251-7-bp@alien8.de> <20170117233124.7ywfh4bvdargbspw@pd.tnic> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20170117233124.7ywfh4bvdargbspw@pd.tnic> User-Agent: NeoMutt/20161014 (1.7.1) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 18, 2017 at 12:31:24AM +0100, Borislav Petkov wrote: > Ah, good catch. I guess I'll have to do here: > > /* Something corrupted the container, invalidate it. */ > eq_id = 0; > break; > > too. Ok, I should've done the below from the beginning. I should be looking at desc->mc which says whether we have found a patch or not. And then prepare retvals accordingly. The equivalence id (eq_id) is then used to signal that fact. And in a future patch, I'll check desc->mc after that function returns and not eq_id. (I had to do eq_id because of the global this_equiv_id but that's gone now too). /* * Scan through the rest of the container to find where it ends. We do * some basic sanity-checking too. */ while (size > 0) { struct microcode_amd *mc; u32 patch_size; hdr = (u32 *)buf; if (hdr[0] != UCODE_UCODE_TYPE) break; /* Sanity-check patch size. */ patch_size = hdr[1]; if (patch_size > PATCH_MAX_SIZE) break; /* Skip patch section header: */ buf += SECTION_HDR_SIZE; size -= SECTION_HDR_SIZE; mc = (struct microcode_amd *)buf; if (eq_id == mc->hdr.processor_rev_id) { desc->psize = patch_size; desc->mc = mc; } buf += patch_size; size -= patch_size; } /* * If we have found a patch (desc->mc), it means we're looking at the * container which has a patch for this CPU so return 0 to mean, @ucode * already points to the proper container. Otherwise, we return the size * we scanned so that we can advance to the next container in the * buffer. */ if (desc->mc) { desc->eq_id = eq_id; desc->data = ucode; desc->size = orig_size - size; return 0; } -- Regards/Gruss, Boris. Good mailing practices for 400: avoid top-posting and trim the reply.