Message ID | 20240201010747.471141-6-david.e.box@linux.intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-47475-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:106:209c:c626 with SMTP id mn5csp186876dyc; Wed, 31 Jan 2024 19:40:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IHs5GPT/TjukiGovFypqX+TAhIH4SIo99eD8U2pQwuiVVf0rv1oyOcoolSMUhRzHE3FlJwG X-Received: by 2002:a05:620a:6225:b0:783:82b0:b67b with SMTP id ou37-20020a05620a622500b0078382b0b67bmr1128723qkn.20.1706758823456; Wed, 31 Jan 2024 19:40:23 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706758823; cv=pass; d=google.com; s=arc-20160816; b=Xo76GtDjRHOWyYytRr9DWtZndp9BNRuiugRcOXYJG4IQgnwrBIj4CMl3rtqtQ3aC4n xrtub8+lTExjNHaTtxgTxKmQsbq0AhHy5Ircot2lIND5J68ZCqYmiHU8Wp6xQUGY6Uj5 dn/mgwoCcAnwKm3upU76EV3/pPyKSfRdSuo535CMnWg59WuJ9yjd8IHQUbB0dy1YruoJ HqIxniIvam51ZzV0Y6dN4VzvOhKTnfvk5GLZM3DOZ9rN0+jh07bI485NXeUo3b04Axk4 ZuDRHmVvoWkKwzyw72/Nj1BsN4u67YBUmwL5YlGnBrhsC1g3uI89lkLZv5mqd6wubejO hXWg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=EjrqG2baowl6gXCIIq3I4ERpspGrKbtXGeiRBwQp4D8=; fh=ipZlgp43AF5iCFdEYmOiLmeAL3+HEcWLtXOGVM1M4Lg=; b=cW+p+CM08ez2/8m5tz/BE4YJvrZvOHuWdljACR5E/0TpEaaMy+hLkbplO6K8BsAK1S UIgRVQ7IX6dI8Lww6IKCS5WbNBJThge0diCkP2ZXZb4/CEhS2a9uJiKOeqaUSYCJW3XX +Dmu7HgPwZWI8IM1p3khtiVsYZUcHeGQp8MK0NBTa0JK7FK+WL3fWLxnklRHfHNCpj+8 VmkYUOrEfr3+R9Tkt30VxfNnTzxpvkrWsIEuxHp9SgjWIEVSzJJ6wVaU6AbMVngycVhE UJ+BgIUqQxY7wrhwdgpGN9fkvt34ezDcp2/zwwPJBALEX6sdPDTc42U/M32S+VZtPUKE HDuw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=KPYbQd+J; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-47475-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47475-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Forwarded-Encrypted: i=1; AJvYcCV5xdzkdsyM9Oj32J6CuK973NVKWjkhtkUaI77D9iwfP3l7GsqVvWHN0g/YUi4tjA+pqATtymJd24IYFjnMZjaLgULKpg== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id b21-20020a05620a04f500b007839c1944f8si9848725qkh.761.2024.01.31.19.40.23 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 19:40:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-47475-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=KPYbQd+J; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-47475-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-47475-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id A0FB41C29D19 for <ouuuleilei@gmail.com>; Thu, 1 Feb 2024 01:11:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 58CBF3FB22; Thu, 1 Feb 2024 01:07:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="KPYbQd+J" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8D4B71EF15; Thu, 1 Feb 2024 01:07:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706749675; cv=none; b=YiX9QLUrMOHKI0F65qVTEl+5n4iovawM92tD1ioKQdnZOa+TFhSJX1Il8/rXZ1dQHeZ0cpGkRIsW4nPZ8CwOHp6XCrTUlo1cO2Y770W4t1uhPUVOn6RyF3BS1mqVmpBRR9j6s/kmtV9D336h55MxvKW1+Yca4H25Od6V0yKNLX4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706749675; c=relaxed/simple; bh=yHNdMgW9yFyo2zPLd2fT4A8rb7bD8WunIVFdY+rWAMY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=WrnF1VULZGV3UwDkvTH7iL9ZbLW2Ymcpsh8MUDGKqPSPFdB+WW1c3DKxIb60lQ8RN/LXE7h3Yj7kYEejvcTpCcUb1go+rUAJfL763ydT2T1yTwgDTArYfPlHA1dwfGogu7HMRf0lNevCrv4SCJ7K/TKpesp0/wa8fGWu2wkRMMM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=KPYbQd+J; arc=none smtp.client-ip=198.175.65.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1706749674; x=1738285674; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=yHNdMgW9yFyo2zPLd2fT4A8rb7bD8WunIVFdY+rWAMY=; b=KPYbQd+J66Hu5+wQD/qzz0Nyhe69dwqqfdbKoroU4j746tDo8p5F2Tv7 Qf817LcZugU7Il9c/tCDKN4PBaaCUxrzADNLY5VXwyaGvhk62B79/DQ1L LbRjEc/OGdsWFAKreT6xfdA20u7ulsJBMyEbDXYvl2jBizvBcU2CNfZOw 57KGnbFdE4amIJKFw5MaO5bivABe+9pHv+C48RJtWWs6Gvj8hIMw4LgDR ek1ytvRxd1SEO1SW2/9uENHB0ivq0KB1FnY+LkyT7/NKT8stRefgixCMg nNjH0o59rI309r7HHfNePtwMq5u1NCPuzvIUwmopQvh/dNMnc6Dj7PXPi Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10969"; a="11145823" X-IronPort-AV: E=Sophos;i="6.05,233,1701158400"; d="scan'208";a="11145823" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Jan 2024 17:07:50 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,233,1701158400"; d="scan'208";a="37057415" Received: from linux.intel.com ([10.54.29.200]) by orviesa001.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Jan 2024 17:07:49 -0800 Received: from debox1-desk4.lan (unknown [10.212.205.115]) by linux.intel.com (Postfix) with ESMTP id 26C98580DF0; Wed, 31 Jan 2024 17:07:49 -0800 (PST) From: "David E. Box" <david.e.box@linux.intel.com> To: netdev@vger.kernel.org, ilpo.jarvinen@linux.intel.com, david.e.box@linux.intel.com, sathyanarayanan.kuppuswamy@linux.intel.com Cc: linux-kernel@vger.kernel.org, platform-driver-x86@vger.kernel.org Subject: [PATCH 5/8] platform/x86/intel/sdsi: Add in-band BIOS lock support Date: Wed, 31 Jan 2024 17:07:44 -0800 Message-Id: <20240201010747.471141-6-david.e.box@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240201010747.471141-1-david.e.box@linux.intel.com> References: <20240201010747.471141-1-david.e.box@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789666340395482066 X-GMAIL-MSGID: 1789666340395482066 |
Series |
Intel On Demand: Add netlink interface for SPDM attestation
|
|
Commit Message
David E. Box
Feb. 1, 2024, 1:07 a.m. UTC
From: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com> As per SDSi in-band interface specification, sec titled "BIOS lock for in-band provisioning", when IB_LOCK bit is set in control qword, the SDSI agent is only allowed to perform the read flow, but not allowed to provision license blob or license key. So add check for it in sdsi_provision(). Signed-off-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com> Signed-off-by: David E. Box <david.e.box@linux.intel.com> --- drivers/platform/x86/intel/sdsi.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
Comments
On Wed, 31 Jan 2024, David E. Box wrote: > From: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com> > > As per SDSi in-band interface specification, sec titled "BIOS lock for > in-band provisioning", when IB_LOCK bit is set in control qword, the > SDSI agent is only allowed to perform the read flow, but not allowed to > provision license blob or license key. So add check for it in > sdsi_provision(). > > Signed-off-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com> > Signed-off-by: David E. Box <david.e.box@linux.intel.com> > --- > drivers/platform/x86/intel/sdsi.c | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/drivers/platform/x86/intel/sdsi.c b/drivers/platform/x86/intel/sdsi.c > index 14821fee249c..287780fe65bb 100644 > --- a/drivers/platform/x86/intel/sdsi.c > +++ b/drivers/platform/x86/intel/sdsi.c > @@ -61,6 +61,7 @@ > #define CTRL_OWNER GENMASK(5, 4) > #define CTRL_COMPLETE BIT(6) > #define CTRL_READY BIT(7) > +#define CTRL_INBAND_LOCK BIT(32) > #define CTRL_STATUS GENMASK(15, 8) > #define CTRL_PACKET_SIZE GENMASK(31, 16) > #define CTRL_MSG_SIZE GENMASK(63, 48) > @@ -331,12 +332,21 @@ static int sdsi_mbox_read(struct sdsi_priv *priv, struct sdsi_mbox_info *info, s > return sdsi_mbox_cmd_read(priv, info, data_size); > } > > +static bool sdsi_ib_locked(struct sdsi_priv *priv) > +{ > + return !!FIELD_GET(CTRL_INBAND_LOCK, readq(priv->control_addr)); > +} > + > static ssize_t sdsi_provision(struct sdsi_priv *priv, char *buf, size_t count, > enum sdsi_command command) > { > struct sdsi_mbox_info info = {}; > int ret; > > + /* Make sure In-band lock is not set */ > + if (sdsi_ib_locked(priv)) > + return -EPERM; > + > if (count > (SDSI_SIZE_WRITE_MSG - SDSI_SIZE_CMD)) > return -EOVERFLOW; Any reason why this order was chosen? I'd prefer these checks be other way around (a stupid caller providing too long count gets notified of its stupidity regardless of the locked state).
diff --git a/drivers/platform/x86/intel/sdsi.c b/drivers/platform/x86/intel/sdsi.c index 14821fee249c..287780fe65bb 100644 --- a/drivers/platform/x86/intel/sdsi.c +++ b/drivers/platform/x86/intel/sdsi.c @@ -61,6 +61,7 @@ #define CTRL_OWNER GENMASK(5, 4) #define CTRL_COMPLETE BIT(6) #define CTRL_READY BIT(7) +#define CTRL_INBAND_LOCK BIT(32) #define CTRL_STATUS GENMASK(15, 8) #define CTRL_PACKET_SIZE GENMASK(31, 16) #define CTRL_MSG_SIZE GENMASK(63, 48) @@ -331,12 +332,21 @@ static int sdsi_mbox_read(struct sdsi_priv *priv, struct sdsi_mbox_info *info, s return sdsi_mbox_cmd_read(priv, info, data_size); } +static bool sdsi_ib_locked(struct sdsi_priv *priv) +{ + return !!FIELD_GET(CTRL_INBAND_LOCK, readq(priv->control_addr)); +} + static ssize_t sdsi_provision(struct sdsi_priv *priv, char *buf, size_t count, enum sdsi_command command) { struct sdsi_mbox_info info = {}; int ret; + /* Make sure In-band lock is not set */ + if (sdsi_ib_locked(priv)) + return -EPERM; + if (count > (SDSI_SIZE_WRITE_MSG - SDSI_SIZE_CMD)) return -EOVERFLOW;