Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1611931pxb; Fri, 27 Aug 2021 12:59:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxV2kbBGlIwDSfZjacEljiIAPO9rmreykJVZRRGD1kQ1yXA0jK13MEeCAUBFjUkf6qoRhRb X-Received: by 2002:aa7:d986:: with SMTP id u6mr11521560eds.156.1630094341215; Fri, 27 Aug 2021 12:59:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630094341; cv=none; d=google.com; s=arc-20160816; b=igKJAo37BfMU02O1H/Ayub//aTmTr8ZlnCok5u8pAya7RhDwkKGHWTb81FBgLXK9cY LUorwkaartr7DVZ4H76fuHWjmEX2dAICPTxtupLEJRAGQxh1C9G00o249FkWmEeJdcOR 9b6aXPnk1dfGDJwLNe69RQ2uDQBZq+qQ8I6hrBrpv+2ebGwGbuXvxQg8SrO5Vq6IHY7L X221xy+gfDHC4Qo3wfg+W5l8roAYmjRoGuAHNsn+GZpm6BvR6seubx48m/iAwkaUNbqm Pff/KV+JhEA/5/qN3261BAlicecvYPzpYEM05X94Sb7sFMd8q6Wb/ExQhmRpmoLSeWD4 eqAw== 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; bh=jYZ9C+DewBMZj0K1oJPPLEBw+qrS3fUdPozOnxPd1Q8=; b=HtG/fRfrMLgDfqMV1aIluu817I5CIEBYlBP45uV4B8hXNBo5d7Y7RcZRzPPycm8v0N +OnqCvDiJJIqIjFbxPewtdTPgzSGLxnnb99f3u/gvKZo7WcUEBDzqOqAVxrZ0vlYEukm xXBHUZ8bERujNdC7IzFHJRd6lQN44NTkBjbEaJC20etePUOCbgWye4eA25yIXQTGEwJl 6mwpPNmLxXh8YF+dMxSvz0KWw3R8CnPzfUXXVIZcLmuB/oxZ2k1PXuv96bHKGvonPm/+ fb/rQtpYWJOu+ie33TAawX1/rg1xgzflY4uK+QwSsIXjxSfCwdEDSTAykjnCIcP3CvM2 2HMg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qb24si7718867ejc.676.2021.08.27.12.58.38; Fri, 27 Aug 2021 12:59:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231526AbhH0T45 (ORCPT + 99 others); Fri, 27 Aug 2021 15:56:57 -0400 Received: from mga09.intel.com ([134.134.136.24]:26659 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231320AbhH0T4q (ORCPT ); Fri, 27 Aug 2021 15:56:46 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10089"; a="218024434" X-IronPort-AV: E=Sophos;i="5.84,357,1620716400"; d="scan'208";a="218024434" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Aug 2021 12:55:56 -0700 X-IronPort-AV: E=Sophos;i="5.84,357,1620716400"; d="scan'208";a="528422087" Received: from agluck-desk2.sc.intel.com ([10.3.52.146]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Aug 2021 12:55:56 -0700 From: Tony Luck To: Sean Christopherson , Jarkko Sakkinen , Dave Hansen Cc: Cathy Zhang , x86@kernel.org, linux-kernel@vger.kernel.org, Tony Luck Subject: [PATCH v4 6/6] x86/sgx: Add hook to error injection address validation Date: Fri, 27 Aug 2021 12:55:43 -0700 Message-Id: <20210827195543.1667168-7-tony.luck@intel.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210827195543.1667168-1-tony.luck@intel.com> References: <20210728204653.1509010-1-tony.luck@intel.com> <20210827195543.1667168-1-tony.luck@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org SGX reserved memory does not appear in the standard address maps. Add hook to call into the SGX code to check if an address is located in SGX memory. There are other challenges in injecting errors into SGX. Update the documentation with a sequence of operations to inject. Signed-off-by: Tony Luck --- .../firmware-guide/acpi/apei/einj.rst | 19 +++++++++++++++++++ drivers/acpi/apei/einj.c | 3 ++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/Documentation/firmware-guide/acpi/apei/einj.rst b/Documentation/firmware-guide/acpi/apei/einj.rst index c042176e1707..55e2331a6438 100644 --- a/Documentation/firmware-guide/acpi/apei/einj.rst +++ b/Documentation/firmware-guide/acpi/apei/einj.rst @@ -181,5 +181,24 @@ You should see something like this in dmesg:: [22715.834759] EDAC sbridge MC3: PROCESSOR 0:306e7 TIME 1422553404 SOCKET 0 APIC 0 [22716.616173] EDAC MC3: 1 CE memory read error on CPU_SrcID#0_Channel#0_DIMM#0 (channel:0 slot:0 page:0x12345 offset:0x0 grain:32 syndrome:0x0 - area:DRAM err_code:0001:0090 socket:0 channel_mask:1 rank:0) +Special notes for injection into SGX enclaves: + +There may be a separate BIOS setup option to enable SGX injection. + +The injection process consists of setting some special memory controller +trigger that will inject the error on the next write to the target +address. But the h/w prevents any software outside of an SGX enclave +from accessing enclave pages (even BIOS SMM mode). + +The following sequence can be used: + 1) Determine physical address of enclave page + 2) Use "notrigger=1" mode to inject (this will setup + the injection address, but will not actually inject) + 3) Enter the enclave + 4) Store data to the virtual address matching physical address from step 1 + 5) Execute CLFLUSH for that virtual address + 6) Spin delay for 250ms + 7) Read from the virtual address. This will trigger the error + For more information about EINJ, please refer to ACPI specification version 4.0, section 17.5 and ACPI 5.0, section 18.6. diff --git a/drivers/acpi/apei/einj.c b/drivers/acpi/apei/einj.c index 2882450c443e..cd7cffc955bf 100644 --- a/drivers/acpi/apei/einj.c +++ b/drivers/acpi/apei/einj.c @@ -544,7 +544,8 @@ static int einj_error_inject(u32 type, u32 flags, u64 param1, u64 param2, ((region_intersects(base_addr, size, IORESOURCE_SYSTEM_RAM, IORES_DESC_NONE) != REGION_INTERSECTS) && (region_intersects(base_addr, size, IORESOURCE_MEM, IORES_DESC_PERSISTENT_MEMORY) - != REGION_INTERSECTS))) + != REGION_INTERSECTS) && + !sgx_is_epc_page(base_addr))) return -EINVAL; inject: -- 2.29.2