Received: by 10.213.65.68 with SMTP id h4csp1320904imn; Wed, 14 Mar 2018 17:06:51 -0700 (PDT) X-Google-Smtp-Source: AG47ELtMqlUlpApCyFu073Yo8tUTlZJAZdappF/IABH+JDVctpHHoYgM14pyLqHEyiEUshSZpycn X-Received: by 10.99.107.9 with SMTP id g9mr5134242pgc.3.1521072411011; Wed, 14 Mar 2018 17:06:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521072410; cv=none; d=google.com; s=arc-20160816; b=ZK9aq1ZuUlduB0n5lMVtLOqWPJO5cVEuWD1xfkoJ5ixz++DwecNONf6cu7eo3xND4m b8qu5X92l9J5RL1Hcq7QJ6Hqa9PcLNmmSGi+YQ0lulHJnsseuSv0xpAM+i3ll5soULVw tXkLCvH7frJP6p/aVnSPDjutFTDrqxnEbVJiwnJVlOClFuhuYPprU9VyGfe0ioDJMozJ VjTH69MQtDG2wSEIEwkZvy3FyuXfRQqwPqVqLt0/1qJlkaB8ro1CvdLxxTw8pFO9HSx4 IFhySLDusATdLXFLDkSVIManzfMbC4d0YvaBgktTGiFEyOpJzkZl3fCrbO+CZGXBnX5+ GtRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=MPf/j8Kcj7NlOzUUm5sEYd7/fNpZwlH25dReLAZww2U=; b=a+VETVDXmk+APDdejap1e34wVRCN/L61rYr1PvA8QRcXwQfVHppXTLDhB0ieTzG8wp IRjZQ6JvLl94zkkpC0ZqVM4Q0nlC9dbE6pjO8Fg555/ceCQxMussSrsGfw07Fg/jayuH XwUMPHcOGRLc3vjXvKvQZ0tXMOjp3syD1AREthI+eGskZOXCNg7QF4x+XOR/G1noKPXU WAmOjfiMK9HHabLEBwLttyUt1IXVBvc98mwDor5OQkhmRzNbs+lAldpVJ1V10ovyiB6+ sDKS3LcOsSH8eNsy/h94K2towsf47psrmeCZzqehVBlgl0Q1kaw0JHVkgwVt8pJzj4U4 CfTg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 69-v6si2787488pla.390.2018.03.14.17.06.36; Wed, 14 Mar 2018 17:06:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751790AbeCOAFR (ORCPT + 99 others); Wed, 14 Mar 2018 20:05:17 -0400 Received: from vps-vb.mhejs.net ([37.28.154.113]:39076 "EHLO vps-vb.mhejs.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751478AbeCOAFQ (ORCPT ); Wed, 14 Mar 2018 20:05:16 -0400 Received: by vps-vb.mhejs.net with esmtps (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ewGOR-0002Sv-6n; Thu, 15 Mar 2018 01:05:15 +0100 Subject: Re: [PATCH v3 4/9] x86/microcode/AMD: automatically compute the PATCH_MAX_SIZE macro To: Borislav Petkov Cc: Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, linux-kernel@vger.kernel.org References: <20180314180209.GH16605@pd.tnic> From: "Maciej S. Szmigiero" Message-ID: Date: Thu, 15 Mar 2018 01:05:14 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180314180209.GH16605@pd.tnic> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 14.03.2018 19:02, Borislav Petkov wrote: > On Tue, Mar 13, 2018 at 10:06:48PM +0100, Maciej S. Szmigiero wrote: >> +/* Maximum of all the above families */ >> +#define PATCH_MAX_SIZE SIMPLE_MAX3(F1XH_MPB_MAX_SIZE, F14H_MPB_MAX_SIZE, \ > > Nope, it should be > > #define PATCH_MAX_SIZE (max_t(unsigned int, FXXH... Unfortunately, this does not work: > ./include/linux/kernel.h:806:41: error: braced-group within expression allowed only inside a function > #define __max(t1, t2, max1, max2, x, y) ({ \ That's because we have a static array containing the chosen microcode patch for the current CPU (amd_ucode_patch) using this macro value as its length. Comments in the code say we can't use vmalloc() during early microcode load so we can't allocate this array dynamically. And if we hardcode its length we don't get the benefits of automatically computing this length as maximum of all family patch sizes (as it should be). Maciej