From patchwork Thu Sep 27 08:50:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 147688 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp1726319lji; Thu, 27 Sep 2018 01:51:08 -0700 (PDT) X-Google-Smtp-Source: ACcGV63z7jfsS15DUBWg2Ps05oqmdIMYTPASk0KjObrY4a4ZBQqSF5RSinlHL5/VWpFPlrKGPG1Z X-Received: by 2002:a63:7419:: with SMTP id p25-v6mr9271318pgc.395.1538038268821; Thu, 27 Sep 2018 01:51:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538038268; cv=none; d=google.com; s=arc-20160816; b=zvchOxlljqjLWUroJPtNB9fqtvsr/dJNJSR6Jb1E1ZSUQQ0j9E58V5uLv8mrx9PbqW dG/lIe/02aODBsgLV/CP3rXFxE85e/1BowQIJ5ct0v6+2M1g0Ix97FWR5I/I569virTt 8ssIGnCk1ty72xbuXmpAPV/Fo0Oy/2yAz08lBBizt1uisfZIr7r9oF8BfB/F/soiS6iH 0RaQM0rtx0yoh1sLRlLhOXeZFShOLiFnKzyx8W7H9VjQcyOsSPmhc0nHa0NoUG5+IVTf 835myGOiM9z4Kqjx6GyyvCihd54Hnh6joIrH9NWAcrRKo41zrEzMAMDAPnGb2YEXtbQZ yNNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=e0MW/cO/rHunfkzsEHUdpPLgA85W8krihEUCPuzlC88=; b=NN2nHBZUHp6RF1/QzDaSp9GYToheNEFhP1udKCitaN4WP3Tl8u4NhpPB+IDbBx5E8x SAs7MaAoBEvs+b/pY2t9/q+Ju43v0yNy+oaOaN3K6r3nGZgH9pB7yE6LeqlJ4mOHdLX1 q9jMwI6hSbaEQgXz1jDB7o65jOOqkj3hOVtSni0fueI18jKhb3EExE5A1gySnHyw+nzN AQHXGczmggWccd9lNPE611X87yUmkUUBRTEIHnDZ6HyUehvHEj7EGgcfgFzdQKCOng3s yZhGbYsFX9hccM9O6KlXNLLwovac+Yr+5n2eC+i048eMN4g6qPFatxAob92146Q03OuC Fb+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bGgdhQcj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l15-v6si1430170pgh.593.2018.09.27.01.51.08; Thu, 27 Sep 2018 01:51:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bGgdhQcj; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727388AbeI0PIO (ORCPT + 32 others); Thu, 27 Sep 2018 11:08:14 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:40374 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727342AbeI0PIN (ORCPT ); Thu, 27 Sep 2018 11:08:13 -0400 Received: by mail-wm1-f65.google.com with SMTP id o2-v6so5067806wmh.5 for ; Thu, 27 Sep 2018 01:51:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=e0MW/cO/rHunfkzsEHUdpPLgA85W8krihEUCPuzlC88=; b=bGgdhQcjPRB3zwnlm4BsD6QNoc7DoaayYxqXj3tpGnCxA4BFot+1qmklGZkf8vt0f8 FUZ9h7MlEKozRybDDRiH5Rnowhy8H+LwMW+SzPKg/XYkL7G9rdxHf+zLGAVgk60moYnt RHe5qMGqHcSGij07vTPWKQB2USWjUmIc+avkc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=e0MW/cO/rHunfkzsEHUdpPLgA85W8krihEUCPuzlC88=; b=Ii6XiSS8nDQAlnG1cI4c/aknaebrN35MW1ZM0QOMXO4MncumC67Bxdiwc8xaj5hd/D 9dFF4aGs3Q0tbaclLTV8Af56GEbfIhv535w9f7NfVbRydX0dG1Zp/NPmla2UUmPvEQNq DLzO9ar25N63RbQVAlMC5RNBOXSqTtE/4lkFq/ayUV1ntABMyQT5YPagsdJhTMuZ8P3H Q1nm8Qf08rcSvxT01evpaRwdc1DwrjkWqnVrMF1iToZrJHk581ek0ImQfyKtxXU6smDS Et4D9Tsd8ke4B4tdvrK1AdmkyP5r3e10KcdaCbP7IgrU8zCZyRUjAiwJNgVBQq+3fBM9 jaeg== X-Gm-Message-State: ABuFfogbKAGEYcTLZam/WCU8DpgY81kKg3VYNIE5bY4p2n8/TSi3OzQ6 kv8+AoE8i+fSRo2SSG507tSKlT6Rtlw= X-Received: by 2002:a1c:4d09:: with SMTP id o9-v6mr6766505wmh.134.1538038263329; Thu, 27 Sep 2018 01:51:03 -0700 (PDT) Received: from rev03.home ([2a01:cb1d:112:6f00:546e:3c44:5966:2f5e]) by smtp.gmail.com with ESMTPSA id p11-v6sm1304055wrd.74.2018.09.27.01.51.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Sep 2018 01:51:02 -0700 (PDT) From: Ard Biesheuvel To: linux-kernel@vger.kernel.org, Ingo Molnar , Thomas Gleixner Cc: Ard Biesheuvel , linux-efi@vger.kernel.org, Aaron Ma , Alistair Strachan , Ben Hutchings , Bhupesh Sharma , Hans de Goede , Ivan Hu , Jeremy Linton , Marc Zyngier , Matt Fleming , Peter Robinson , Sai Praneeth Prakhya , Sebastian Andrzej Siewior , Stefan Agner Subject: [PATCH 05/11] efi/efi_test: add exporting ResetSystem runtime service Date: Thu, 27 Sep 2018 10:50:32 +0200 Message-Id: <20180927085039.8391-6-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180927085039.8391-1-ard.biesheuvel@linaro.org> References: <20180927085039.8391-1-ard.biesheuvel@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ivan Hu Add exporting the UEFI runtime service ResetSystem for upper application or test tools to use. Signed-off-by: Ivan Hu Signed-off-by: Ard Biesheuvel --- drivers/firmware/efi/test/efi_test.c | 27 +++++++++++++++++++++++++++ drivers/firmware/efi/test/efi_test.h | 10 ++++++++++ 2 files changed, 37 insertions(+) -- 2.18.0 diff --git a/drivers/firmware/efi/test/efi_test.c b/drivers/firmware/efi/test/efi_test.c index 41c48a1e8baa..769640940c9f 100644 --- a/drivers/firmware/efi/test/efi_test.c +++ b/drivers/firmware/efi/test/efi_test.c @@ -542,6 +542,30 @@ static long efi_runtime_get_nexthighmonocount(unsigned long arg) return 0; } +static long efi_runtime_reset_system(unsigned long arg) +{ + struct efi_resetsystem __user *resetsystem_user; + struct efi_resetsystem resetsystem; + void *data = NULL; + + resetsystem_user = (struct efi_resetsystem __user *)arg; + if (copy_from_user(&resetsystem, resetsystem_user, + sizeof(resetsystem))) + return -EFAULT; + if (resetsystem.data_size != 0) { + data = memdup_user((void *)resetsystem.data, + resetsystem.data_size); + if (IS_ERR(data)) + return PTR_ERR(data); + } + + efi.reset_system(resetsystem.reset_type, resetsystem.status, + resetsystem.data_size, (efi_char16_t *)data); + + kfree(data); + return 0; +} + static long efi_runtime_query_variableinfo(unsigned long arg) { struct efi_queryvariableinfo __user *queryvariableinfo_user; @@ -682,6 +706,9 @@ static long efi_test_ioctl(struct file *file, unsigned int cmd, case EFI_RUNTIME_QUERY_CAPSULECAPABILITIES: return efi_runtime_query_capsulecaps(arg); + + case EFI_RUNTIME_RESET_SYSTEM: + return efi_runtime_reset_system(arg); } return -ENOTTY; diff --git a/drivers/firmware/efi/test/efi_test.h b/drivers/firmware/efi/test/efi_test.h index 9812c6a02b40..5f4818bf112f 100644 --- a/drivers/firmware/efi/test/efi_test.h +++ b/drivers/firmware/efi/test/efi_test.h @@ -81,6 +81,13 @@ struct efi_querycapsulecapabilities { efi_status_t *status; } __packed; +struct efi_resetsystem { + int reset_type; + efi_status_t status; + unsigned long data_size; + efi_char16_t *data; +} __packed; + #define EFI_RUNTIME_GET_VARIABLE \ _IOWR('p', 0x01, struct efi_getvariable) #define EFI_RUNTIME_SET_VARIABLE \ @@ -108,4 +115,7 @@ struct efi_querycapsulecapabilities { #define EFI_RUNTIME_QUERY_CAPSULECAPABILITIES \ _IOR('p', 0x0A, struct efi_querycapsulecapabilities) +#define EFI_RUNTIME_RESET_SYSTEM \ + _IOW('p', 0x0B, struct efi_resetsystem) + #endif /* _DRIVERS_FIRMWARE_EFI_TEST_H_ */