Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp2242188rbb; Tue, 27 Feb 2024 16:01:14 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWkrsmg8FcmptwSnmpG2qLLcB0inhsbd+iIqMDAC7s6Vle1mn5sbG/ywpPA3LbVb1FkWKXHZt05xve6sn5DxssJU7z68v32StFFABis3A== X-Google-Smtp-Source: AGHT+IFKZGqxqGinkfhWh1Nu8Xc1oE1uWvA5cxINBscD/LK00nddEfTXdkSBFwlW+XwiBqIoKMf6 X-Received: by 2002:a05:6402:5188:b0:565:965f:b0f2 with SMTP id q8-20020a056402518800b00565965fb0f2mr9859039edd.5.1709078474597; Tue, 27 Feb 2024 16:01:14 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709078474; cv=pass; d=google.com; s=arc-20160816; b=GY4XXXmLLOf/o5mlFhRjViRBmkfl7OsM3nhn1hM/PBU62m+MSrrn2JOXwhuKJZAjcx Lwpo/CHB/vXgOKNwwH/c7eidIt+iv+FhQFCYIYzsdTevSzFmbFI3jZmfBNIOJa6Nyu30 ATx7+QWwFHkyFtZWiwNitfgDkDSH2HmJG6qaGTDt5rKcxex+VI2LUJaUcGgFVIM8/gl3 qVUnylarSUDl/CvdeozG8Hxk3HkADGuhy0ViBjZkBSOk43orjzY93ikE8nzZey2/IaxL gUD11x7Y2GFJ4Ocu2z9Bsaqqib2ayz0gqnfrlqycAxFABZWHU2l75YhQjEAQzeJTRVG8 avtw== 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:to:from:dkim-signature; bh=2seSwZ5UfL6cWXX5apWHQ8Rll6Uk4Y1qyEy1olnGjqA=; fh=x4bFVqj5qD52f35ITnpIMR9XPjt+nAjpv5WW2CLFX0Q=; b=M+1oLHCORpVNfABmf8B5H+StBohJsHSDVY6NXszutTfc193nPSHwJCQiLRQlVSIovG E3s969xB1abI/hkzBxwliMj7OLsrN247XXLSwCpQfQ422Xi18XmHVPvyZbDBQf/ip2Sj kSOPjgYox9gekbSYcGh+Y9us+wZl5MYVypfoiWrWHM9NELpQH34MWdcmZxZ4GhHjgggm eAq81pqF4//Mx4PxAxAWG21RF2UfkpfqrvvlqCf29+PUDCN+ycPjWfn9RtmVN9MCKUV/ geCQi2DRq9CcsyFbNvC+Y7l0h83Ep3m8ZdS59Oy7jW8lsgEODC3m6vpCRKIcas56y9yn qp6A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=WILPckTW; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-84246-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84246-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id d3-20020aa7ce03000000b0056617d528edsi1084853edv.499.2024.02.27.16.01.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 16:01:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-84246-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=WILPckTW; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-84246-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-84246-linux.lists.archive=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 am.mirrors.kernel.org (Postfix) with ESMTPS id 59F311F23EFA for ; Wed, 28 Feb 2024 00:01:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3CD9728DBF; Wed, 28 Feb 2024 00:00:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="WILPckTW" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.13]) (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 9CF22364; Wed, 28 Feb 2024 00:00:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.13 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709078421; cv=none; b=a7LP5QPfAMJGwSArDZH1nl0KOFSq5DZJJd4aSPLBUt6NDvH6xq9JtzDENYEPZA8wI1N1OFi2ctbVfoh4ogXsOzSq0Xe11KZ7cRqzaP8T6hK5/wEOj821i5h8tcNBvc7Sk0c0aY8Hwcovt+ukERcGegVP5R31abxkmfZM4FWRNj4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709078421; c=relaxed/simple; bh=Cjids9Y5fgG2A+arpd84T9h3UMgARRlLtTbh6HeGD1E=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=fbkEQWP4A3vjoepFOcYwLuaxVHVojv7JzWP5b2GHhRVGfcvF0GFlrt8gKBYTNYqq2mMTRpQMt2Nf97vAitj1VrcyHEjuuLiLqOfxHCpc2Oft7TRhcdp5/eFeasAJkBD2M3CQyCvcAdg65NXsVH9vdoX+xFC4DII2AmKTAzvUVIg= 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=WILPckTW; arc=none smtp.client-ip=198.175.65.13 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=1709078420; x=1740614420; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=Cjids9Y5fgG2A+arpd84T9h3UMgARRlLtTbh6HeGD1E=; b=WILPckTWAqOQTDXh4nWq56bwd7ShdkPP7fXKWTvWL+9ASN93Un5i6iJ3 ZNqH2qszStxHmYISDEaRBdiVxOvQX7cwQiDWwd8UMHdReGJibT96OO6cf Ezw1GJLCFt8hmaOmxCEZlNzOsKq5Ndjht2uB9AePm0QbHdshduZOVF71s 9OEWwLP6Ap9eCqM19mkmF2DdQvLzRWiy14w5ZRikHV26B5vnIypkdXkdm U3+s8hAAKK970RIte1aVYeqdVuwI0e653fX1JZQoszAF+puoAybm3D0OK aiOt40iVmBr6jrfP95LaQL4q5gF0HEPYKq+GlJ20GmVOVPXCCykGz19PH Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10996"; a="14604937" X-IronPort-AV: E=Sophos;i="6.06,189,1705392000"; d="scan'208";a="14604937" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by orvoesa105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Feb 2024 16:00:17 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,189,1705392000"; d="scan'208";a="7176940" Received: from linux.intel.com ([10.54.29.200]) by orviesa010.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Feb 2024 16:00:17 -0800 Received: from debox1-desk4.lan (unknown [10.251.6.149]) by linux.intel.com (Postfix) with ESMTP id D44BF580D7F; Tue, 27 Feb 2024 16:00:16 -0800 (PST) From: "David E. Box" To: david.e.box@linux.intel.com, rajvi.jingar@linux.intel.com, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, hdegoede@redhat.com, ilpo.jarvinen@linux.intel.com Subject: [PATCH V2 3/9] platform/x86/intel/sdsi: Add in-band BIOS lock support Date: Tue, 27 Feb 2024 16:00:10 -0800 Message-Id: <20240228000016.1685518-4-david.e.box@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240228000016.1685518-1-david.e.box@linux.intel.com> References: <20240228000016.1685518-1-david.e.box@linux.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Kuppuswamy Sathyanarayanan 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 Signed-off-by: David E. Box --- V2 - Move sdsi_ib_locked() check after overflow check 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 d80c2dc0ce71..bb3eaf5eb382 100644 --- a/drivers/platform/x86/intel/sdsi.c +++ b/drivers/platform/x86/intel/sdsi.c @@ -67,6 +67,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) @@ -346,6 +347,11 @@ 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) { @@ -355,6 +361,10 @@ static ssize_t sdsi_provision(struct sdsi_priv *priv, char *buf, size_t count, if (count > (SDSI_SIZE_WRITE_MSG - SDSI_SIZE_CMD)) return -EOVERFLOW; + /* Make sure In-band lock is not set */ + if (sdsi_ib_locked(priv)) + return -EPERM; + /* Qword aligned message + command qword */ info.size = round_up(count, SDSI_SIZE_CMD) + SDSI_SIZE_CMD; -- 2.34.1