From patchwork Wed Jul 8 03:32:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1324908 X-Patchwork-Delegate: bmeng.cn@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=gC4oFa5s; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4B1lSS4fQFz9s1x for ; Wed, 8 Jul 2020 13:40:24 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A1007822C2; Wed, 8 Jul 2020 05:34:23 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="gC4oFa5s"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B37FC8227E; Wed, 8 Jul 2020 05:34:05 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x141.google.com (mail-il1-x141.google.com [IPv6:2607:f8b0:4864:20::141]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 30D9B82272 for ; Wed, 8 Jul 2020 05:34:02 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-il1-x141.google.com with SMTP id a6so21144923ilq.13 for ; Tue, 07 Jul 2020 20:34:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=eX48t5TzrKqeB1lywFJcY9wPROGJivJauI/kN4aUURU=; b=gC4oFa5srMJSTuOE7pWEvAlRuHzZWuqXlgFA9/tLmRKv7rV2taRELY378SvGU5fQi6 3J6jSZb0nGoYH1YfHljygivve0Dj5iEwV0zyfB/sap3TBiPq8BB+H+FskdTX5AtdEp+3 d00EWN4bgw+Y36xjNHS4QBBdxDe4GyCMNS9Rw= 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:mime-version:content-transfer-encoding; bh=eX48t5TzrKqeB1lywFJcY9wPROGJivJauI/kN4aUURU=; b=Iy7j6+lw2Yv6v6ryR8UBkotHOuid1r7cD/h2ERldWs+OFynTEL3fsV/fdL8eU+m9nm mwzxVfondRHx/DEQ/UqaLIBwXoQyetgfirGWMQQIB2+I3hpai6MRRjmLGMqxDaA50KYq J3uZYZC84KWG43rBLWTJ6ze20xOEOcUH/3PyPNZlt30ruhNlye+pXAUb20q8smbV9VIn s2Bu73uHwDvongd/78yQzA2nY9bKeub33A9tMhTdh3qPFKovAxOoassa1RAzXUfeTUSe s+onVBy9phbppiLdCP1PgVnCovCaqwE/tVbxeZx8znlVQkYg9CwycFh4Ow21MpNby2iu 0Uyg== X-Gm-Message-State: AOAM530hiT8xh1seOkC3kua8rTSg5jl/al1Sb/tDo0v47+f3Sufun6e5 0kuGXlWzHUgDrgWpUWO+ZMtaJPrnXVWkuQ== X-Google-Smtp-Source: ABdhPJwobGRKCZbHwF1OQ398u/P8iWonxIz/peZWKGotmjU0//fQEOdS2PVAMsyjqGW/ItTHKPy9Ug== X-Received: by 2002:a92:4913:: with SMTP id w19mr36752892ila.185.1594179240926; Tue, 07 Jul 2020 20:34:00 -0700 (PDT) Received: from localhost.localdomain (c-73-14-175-90.hsd1.co.comcast.net. [73.14.175.90]) by smtp.gmail.com with ESMTPSA id k1sm13970230ilr.35.2020.07.07.20.34.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jul 2020 20:34:00 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Andy Shevchenko , Bin Meng , Wolfgang Wallner , Simon Glass Subject: [PATCH v2 23/44] x86: Add error checking for csrt table generation Date: Tue, 7 Jul 2020 21:32:24 -0600 Message-Id: <20200708033246.2626378-13-sjg@chromium.org> X-Mailer: git-send-email 2.27.0.383.g050319c2ae-goog In-Reply-To: <20200708033246.2626378-1-sjg@chromium.org> References: <20200708033246.2626378-1-sjg@chromium.org> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean Generation of this table can fail, so update the function to return an error code. Reviewed-by: Bin Meng Reviewed-by: Wolfgang Wallner Signed-off-by: Simon Glass --- (no changes since v1) Changes in v1: - Add new patch to add error checking for csrt table generation arch/x86/lib/acpi_table.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/arch/x86/lib/acpi_table.c b/arch/x86/lib/acpi_table.c index 8219376e17..d2bc3386eb 100644 --- a/arch/x86/lib/acpi_table.c +++ b/arch/x86/lib/acpi_table.c @@ -212,13 +212,14 @@ static void acpi_create_mcfg(struct acpi_mcfg *mcfg) __weak u32 acpi_fill_csrt(u32 current) { - return current; + return 0; } -static void acpi_create_csrt(struct acpi_csrt *csrt) +static int acpi_create_csrt(struct acpi_csrt *csrt) { struct acpi_table_header *header = &(csrt->header); u32 current = (u32)csrt + sizeof(struct acpi_csrt); + uint ptr; memset((void *)csrt, 0, sizeof(struct acpi_csrt)); @@ -227,11 +228,16 @@ static void acpi_create_csrt(struct acpi_csrt *csrt) header->length = sizeof(struct acpi_csrt); header->revision = 0; - current = acpi_fill_csrt(current); + ptr = acpi_fill_csrt(current); + if (!ptr) + return -ENOENT; + current = ptr; /* (Re)calculate length and checksum */ header->length = current - (u32)csrt; header->checksum = table_compute_checksum((void *)csrt, header->length); + + return 0; } static void acpi_create_spcr(struct acpi_spcr *spcr) @@ -482,9 +488,10 @@ ulong write_acpi_tables(ulong start_addr) debug("ACPI: * CSRT\n"); csrt = ctx->current; - acpi_create_csrt(csrt); - acpi_inc_align(ctx, csrt->header.length); - acpi_add_table(ctx, csrt); + if (!acpi_create_csrt(csrt)) { + acpi_inc_align(ctx, csrt->header.length); + acpi_add_table(ctx, csrt); + } debug("ACPI: * SPCR\n"); spcr = ctx->current;