Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp2830525rwi; Tue, 1 Nov 2022 12:18:09 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4CSHVomoZW24FAiArRzxffANTgerlDIKNLaZx2xQ9/HQB7r4BwqSv1yE5wDooD3z8jqTvc X-Received: by 2002:a17:90a:b792:b0:214:2a4a:4bbc with SMTP id m18-20020a17090ab79200b002142a4a4bbcmr34792pjr.81.1667330288871; Tue, 01 Nov 2022 12:18:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667330288; cv=none; d=google.com; s=arc-20160816; b=aZSWoMDOeAIOyol4Aisq3xnIR2qw2HO91uDl5yV9qcn6q2/RiYz2ajlCf9Q4oLh0KQ wt+KZ/50RFIIgX+lx9a8Ph4xho1RkIpTrZZsjRBY7jC8PqkMDKjlNeDdZ2K3Q1WWJS1a UEPc0UW8cKr3MmekNFBLiYVVHSarFhjgXwV2P8fFnzbCvov0si3kyYK+JTLVUkf4qx15 XuH2CQWbfcNN7N1cRoiOdSck0gtID6kO5WGwVtJJ7p8M1dhSYG35c1id93bi2AappR/g w3vHSQZroAhMX05cNX7/KSU4FWddNXpaD5CS8iG1z5D4VgikDT02oTSc2ZhKhsGD1kLT qzsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=UA+kF77Z0GHDnE2lpYaabdNOO6sfWvReFhs7qqb5JD8=; b=SNp0Tn4hmn2PVWthX2jrJQ6htMBkBcgeyBWwskNgsB1bdG5c6YgD0S9Sr5ETYvz20Q VMae3adRjZevqoQu0w8Y66oPs4pvjsso+eX6cQqQPuM6shBQU2hVUJJB6IYoKPQcvm9i 4C3qwqu8ja4BWihQoaPRLj3/Y2O5eXvxuyf7Ty8aTdeQKFXzW8TZKfgVfJQipCqlqMf6 +vaIdBwbFF+DJsb4Lv8N8x+cE7/4FaZ9BjTgaNNt4/Fhunttv3hG7U31YahyVxzwQReu iiYGWHY8ITBVwdSG/W+WxVzhXbJV5Vz2PxGJqDis/GPIeTrcMNWLKtlgZocpZLq6y/89 3uKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=QLggou5E; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p3-20020a170902e74300b001872cf119f1si2697157plf.551.2022.11.01.12.17.54; Tue, 01 Nov 2022 12:18:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=QLggou5E; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230335AbiKATK5 (ORCPT + 97 others); Tue, 1 Nov 2022 15:10:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229962AbiKATKy (ORCPT ); Tue, 1 Nov 2022 15:10:54 -0400 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5205E1CB10; Tue, 1 Nov 2022 12:10:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1667329853; x=1698865853; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=O/S/QsYQFEc16tb+lsIX+I1kIQ7ZiqtVom56wMadWUw=; b=QLggou5E+XtCmjABTe4FfFR3evE61KL16DFgkhCuhAKrwSUEe4/2RmlG v1+95X0wQ35GPNXlS5tP7Fa5kDzHHtauO4m85NtRGGx+WLIR5rCFrGPw4 cLE5gXK4+mSyqoLIQCArulf1CO8otHav0iIcL6cDLmNUmAzRnYPICNQxS gQU/fP9TWmrMP2+p+fQqU/BcqdfyCS0fXpBU1MjjFwiu3dQyogdWFKy2n XBfwL5hqsaiS6+7uXGAZvwjFsoUpuzwRopFlMH/m/4MhWYyl0J6pvyb2e tJ6tBbqzSBy5TdIxTYZk3Abl4ZrJTJOAp4oqLJr7sicO3m+/S/3SvN356 Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10518"; a="335892059" X-IronPort-AV: E=Sophos;i="5.95,231,1661842800"; d="scan'208";a="335892059" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Nov 2022 12:10:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10518"; a="585114145" X-IronPort-AV: E=Sophos;i="5.95,231,1661842800"; d="scan'208";a="585114145" Received: from linux.intel.com ([10.54.29.200]) by orsmga003.jf.intel.com with ESMTP; 01 Nov 2022 12:10:27 -0700 Received: from debox1-desk4.intel.com (unknown [10.212.195.64]) by linux.intel.com (Postfix) with ESMTP id 6739D580B9D; Tue, 1 Nov 2022 12:10:27 -0700 (PDT) From: "David E. Box" To: hdegoede@redhat.com, markgross@kernel.org, andriy.shevchenko@linux.intel.com, srinivas.pandruvada@intel.com Cc: "David E. Box" , platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 8/9] tools/arch/x86: intel_sdsi: Add support for new GUID Date: Tue, 1 Nov 2022 12:10:22 -0700 Message-Id: <20221101191023.4150315-9-david.e.box@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221101191023.4150315-1-david.e.box@linux.intel.com> References: <20221101191023.4150315-1-david.e.box@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The structure and content of the On Demand registers is based on the GUID which is read from hardware through sysfs. Add support for decoding the registers of a new GUID 0xF210D9EF. Signed-off-by: David E. Box --- tools/arch/x86/intel_sdsi/intel_sdsi.c | 32 ++++++++++++++++++-------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/tools/arch/x86/intel_sdsi/intel_sdsi.c b/tools/arch/x86/intel_sdsi/intel_sdsi.c index 01b5f9994e11..0680eda78b1a 100644 --- a/tools/arch/x86/intel_sdsi/intel_sdsi.c +++ b/tools/arch/x86/intel_sdsi/intel_sdsi.c @@ -35,7 +35,8 @@ #define SDSI_DEV "intel_vsec.sdsi" #define AUX_DEV_PATH "/sys/bus/auxiliary/devices/" #define SDSI_PATH (AUX_DEV_DIR SDSI_DEV) -#define GUID 0x6dd191 +#define GUID_V1 0x6dd191 +#define GUID_V2 0xF210D9EF #define REGISTERS_MIN_SIZE 72 #define STATE_CERT_MAX_SIZE 4096 #define STATE_MAX_NUM_LICENSES 16 @@ -100,9 +101,17 @@ struct sdsi_regs { struct availability prov_avail; struct nvram_update_limit limits; uint64_t pcu_cr3_capid_cfg; - uint64_t socket_id; + union { + struct { + uint64_t socket_id; + } v1; + struct { + uint64_t reserved; + uint64_t socket_id; + uint64_t reserved2; + } v2; + } extra; }; - #define CONTENT_TYPE_LK_ENC 0xD #define CONTENT_TYPE_LK_BLOB_ENC 0xE @@ -146,7 +155,7 @@ struct sdsi_dev { struct state_certificate sc; char *dev_name; char *dev_path; - int guid; + uint32_t guid; }; enum command { @@ -199,7 +208,7 @@ static int sdsi_update_registers(struct sdsi_dev *s) return -1; } - if (s->guid != GUID) { + if (s->guid != GUID_V1 && s->guid != GUID_V2) { fprintf(stderr, "Unrecognized guid, 0x%x\n", s->guid); fclose(regs_ptr); return -1; @@ -207,7 +216,7 @@ static int sdsi_update_registers(struct sdsi_dev *s) /* Update register info for this guid */ ret = fread(&s->regs, sizeof(uint8_t), sizeof(s->regs), regs_ptr); - if (ret != sizeof(s->regs)) { + if (ret > (int)sizeof(s->regs)) { /* FIXME: Check size by guid */ fprintf(stderr, "Could not read 'registers' file\n"); fclose(regs_ptr); return -1; @@ -252,10 +261,13 @@ static int sdsi_read_reg(struct sdsi_dev *s) printf(" Updates Available: %d\n", s->regs.prov_avail.available); printf(" Updates Threshold: %d\n", s->regs.prov_avail.threshold); printf("NVRAM Udate Limit\n"); - printf(" 50%% Limit Reached: %s\n", !!s->regs.limits.sdsi_50_pct ? "Yes" : "No"); - printf(" 75%% Limit Reached: %s\n", !!s->regs.limits.sdsi_75_pct ? "Yes" : "No"); - printf(" 90%% Limit Reached: %s\n", !!s->regs.limits.sdsi_90_pct ? "Yes" : "No"); - printf("Socket ID: %ld\n", s->regs.socket_id & 0xF); + printf(" 50%% Limit Reached: %s\n", !!s->regs.limits.sdsi_50_pct ? "Yes" : "No"); + printf(" 75%% Limit Reached: %s\n", !!s->regs.limits.sdsi_75_pct ? "Yes" : "No"); + printf(" 90%% Limit Reached: %s\n", !!s->regs.limits.sdsi_90_pct ? "Yes" : "No"); + if (s->guid == GUID_V1) + printf("Socket ID: %ld\n", s->regs.extra.v1.socket_id & 0xF); + else + printf("Socket ID: %ld\n", s->regs.extra.v2.socket_id & 0xF); return 0; } -- 2.25.1