From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B9499C25B79 for ; Fri, 24 May 2024 10:32:31 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.729293.1134396 (Exim 4.92) (envelope-from ) id 1sASDV-0001J2-0F; Fri, 24 May 2024 10:32:05 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 729293.1134396; Fri, 24 May 2024 10:32:04 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sASDU-0001Iv-Tf; Fri, 24 May 2024 10:32:04 +0000 Received: by outflank-mailman (input) for mailman id 729293; Fri, 24 May 2024 10:32:03 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sASDT-0001HK-HJ for xen-devel@lists.xenproject.org; Fri, 24 May 2024 10:32:03 +0000 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [2a00:1450:4864:20::434]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id db168bd8-19b8-11ef-b4bb-af5377834399; Fri, 24 May 2024 12:32:01 +0200 (CEST) Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-355080e6ff9so497269f8f.2 for ; Fri, 24 May 2024 03:32:01 -0700 (PDT) Received: from [192.168.0.16] (0545937c.skybroadband.com. [5.69.147.124]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3557a08aba8sm1269932f8f.42.2024.05.24.03.31.59 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 24 May 2024 03:32:00 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: db168bd8-19b8-11ef-b4bb-af5377834399 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.com; s=cloud; t=1716546721; x=1717151521; darn=lists.xenproject.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=/j1AH2CW1D72ZHr3W8o3rzzMsGfMwZCkPJJE+Ii7QK8=; b=AlTZbcRy8yjW4YWNh41T4CVLrToPhFXsqosbyE4W3cfu0Cg8VXVbqdfCXIPRUK9ZHH 2UTkHUtTATUcbfcM97Y6xIwrL9Emph6DCCd4NNR1iqbrgqOyswWW/fDt8wa4jWAbzt6P RhnwyoeViOb0sRSuq1DU4LYb4qW/hcX++WVG4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716546721; x=1717151521; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=/j1AH2CW1D72ZHr3W8o3rzzMsGfMwZCkPJJE+Ii7QK8=; b=uDM8Sgu8rlbgAFpRPOgQYa07cSlm9UEv7IPS3DbtnFvoTt7I8ZTCc5QKnXgB3zp/+k RGHBc10Q2wyZR149Mg8u0swrwOu6N4q+AWsizG30Bs9ydFyYA4t9P3ieVZXkDg7pq+tz bgXpTCrnnxBa3I33089bOuRIrzject8YqpVEfdjdc9aSH6p13bKphl2xJO4coep6lLnc e4NALfZUS3GEPDEdmr1EGHZxeL+15sLUTCxuz77gEx00Iu7h0FSkW6VpJub7jJ7BNpDk mDNKMW1RtuSTMiSOiPKvUE5MfCzxMPbN1K2FDmqCNHpL2My4MxPlWKu0z0tAqfBubX2k ZsPA== X-Gm-Message-State: AOJu0Yy1oLBRJugl49CDNFY5u4KEiIB4R1kf5iiLBKA3hwa+s48nKu5W jS3w7/qbc3saQtw2VLSc5GGBjfST1BEUVXLFZhSmIaMLwNJHkDrOCoNPvDfHfEc= X-Google-Smtp-Source: AGHT+IFAdmBE26nT1NqSf+apueplaOS+4Wh9gEgmrQZMeYVdmDMTDYFFSGA4t30yjSDOwCshjNFq3A== X-Received: by 2002:adf:e402:0:b0:34a:2852:f119 with SMTP id ffacd0b85a97d-3552fda1cffmr1100385f8f.36.1716546720766; Fri, 24 May 2024 03:32:00 -0700 (PDT) Message-ID: Date: Fri, 24 May 2024 11:31:58 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3 2/2] tools/xg: Clean up xend-style overrides for CPU policies To: =?UTF-8?Q?Roger_Pau_Monn=C3=A9?= Cc: Xen-devel , Anthony PERARD , Juergen Gross References: Content-Language: en-GB From: Alejandro Vallejo In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 23/05/2024 11:47, Roger Pau Monné wrote: >> -static xen_cpuid_leaf_t *find_leaf( >> - xen_cpuid_leaf_t *leaves, unsigned int nr_leaves, >> - const struct xc_xend_cpuid *xend) >> +static xen_cpuid_leaf_t *find_leaf(xc_cpu_policy_t *p, >> + const struct xc_xend_cpuid *xend) >> { >> const xen_cpuid_leaf_t key = { xend->leaf, xend->subleaf }; >> >> - return bsearch(&key, leaves, nr_leaves, sizeof(*leaves), compare_leaves); >> + return bsearch(&key, p->leaves, ARRAY_SIZE(p->leaves), > > Don't you need to use p->nr_leaves here, as otherwise we could check > against possibly uninitialized leaves (or leaves with stale data)? Indeed. Good catch (same on the MSR side). >> - switch ( p->policy.x86_vendor ) >> + switch ( cur->policy.x86_vendor ) >> { >> case X86_VENDOR_INTEL: >> - for ( i = 0; (p->policy.cache.subleaf[i].type && >> - i < ARRAY_SIZE(p->policy.cache.raw)); ++i ) >> + for ( i = 0; (cur->policy.cache.subleaf[i].type && >> + i < ARRAY_SIZE(cur->policy.cache.raw)); ++i ) > > Nit: indentation is weird here. I would use: > > for ( i = 0; cur->policy.cache.subleaf[i].type && > i < ARRAY_SIZE(cur->policy.cache.raw); ++i ) > > Thanks, Roger. Sure. Leftover from removing the size_t in v2. Cheers, Alejandro