Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp1194902ybj; Thu, 7 May 2020 17:30:04 -0700 (PDT) X-Google-Smtp-Source: APiQypLre1l4vq8Qjk0Dhkj6PnGE2rvIW4IRWvNpHp3asJssfRvgS17ymKdkLBvc1LBXKb0LNxsI X-Received: by 2002:a17:906:804a:: with SMTP id x10mr15322116ejw.86.1588897804367; Thu, 07 May 2020 17:30:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588897804; cv=none; d=google.com; s=arc-20160816; b=HBHOwMPQu5xmYpSCAsdW9b0YbZz3Tx48NM9LmCNwhgzHv0eXQiu++3NWlPUE4prT+z /3w5mcoRVhhbj0zrhJSGyaCpXLiYAcC0yti19k4PSZs0mm8IQix8p+1IwmHujrLPNlY5 S+6Ep4vy5/3/RuKug1FGAUjI/AWrb21InxfMa/JhPhq6tSnSm4/gnQO+lF+qtmJbdBxa 4EtO30oU4NGk9+fsEnGX2NBX6PFdPPjtXFlGfD0yKYUuuvCIlQRrvi3cg2hfZR7Fattb FvvNz3+P/QkJ9texl8cUNTkfwmpMOC+r1DACfcdugxQCYtG4xKRmLMadD8lM5yP6khAo KVrA== 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=JPCDjhWyTHrRtN+IrpzH/X2NJ9wHqJH6zPza8eFFddg=; b=NL3QpwD5Eo/PtNSDxU+i6nIDOQrEgkKLJegLVVPjiWcwZJFvOJ1XOXLeQTae/t3hnA She4GNyx3zss7clxXQN7hAimiqTF6K/o8POUqDgdHxvSaDXz2wqgRd6QSRglDu4y373T qAK1fD7eg0YlZgaqETvt5AxbLYSQlLKJRfKki4qx4SKoEP0NR8Q4uFnTprnXc9a5oF/0 eJCFsA6mGjvOyS7CNUslF+IYl5K3HFKM2v6bJV6BZd+OndYS7gj6z2a+DJR08Vd0jTJm Tl3XqiNpMoiIfDjLx62C+8fHZ51IJ2Tr6p6K2lIwBGOw2HDL/z8Jnk1A8z6rGxlwXRdb QMrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=NWrgZQGn; 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=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f6si18528edw.325.2020.05.07.17.29.41; Thu, 07 May 2020 17:30:04 -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; dkim=pass header.i=@broadcom.com header.s=google header.b=NWrgZQGn; 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=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727051AbgEHA2G (ORCPT + 99 others); Thu, 7 May 2020 20:28:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726638AbgEHA2E (ORCPT ); Thu, 7 May 2020 20:28:04 -0400 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A30E1C05BD43 for ; Thu, 7 May 2020 17:28:04 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id a5so3428384pjh.2 for ; Thu, 07 May 2020 17:28:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=JPCDjhWyTHrRtN+IrpzH/X2NJ9wHqJH6zPza8eFFddg=; b=NWrgZQGnoz5mabDl41Gd4bX6CKcX+TtShgUgAqyBQ4CmcFzkTIh+s4eTOB0O8IQpqt SVCmAIes8s9xPwo6zgaPiHYVGOKb7DgRCJ82VqrXHR8tZaT1RHb8beUkwRbwO+/YumY+ pX4Lb3kGToGG+XOmT86DxbdP3RWi3/OgDiUcg= 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=JPCDjhWyTHrRtN+IrpzH/X2NJ9wHqJH6zPza8eFFddg=; b=A+yYKwJV+IbsjPGsZZ03GvwLGup7wqVi8Dvps7t5KS0QcCYsP2lCaK1dOG0Gxsub+v pjA6WRHYp6M7DkjkfjLU1dBiz8OhpiZnjrcd1qh83r5CxHpRexaoqbkGUyTMf/mDCVSQ KrwJEEw1iUKQ92vMC0zvBEXu5B1vY1kwxOjcDg1ltZ+hB4CBLKUo9RISkZYI+qKnzIfw 46RLFcawyAaVwJEzwjgwG6isS4Rdrm4FIUoQiioPrdaTkqmt9fxga6K82Wb94EJgc6tw P+A2mk3lVG5EFNInJqp2pytdNk4F3QD0hqvOCS2pyF0bclXNp9Y+009Mp8ENp5QaBk9p jPhw== X-Gm-Message-State: AGi0PubzVdEavArwlO0zI+gZS0yfRdeiDvQRvq56Qs+7T5pSPTiWP1N0 Q413XeoOB6+jXw8TEmq1R8Lm8A== X-Received: by 2002:a17:902:b114:: with SMTP id q20mr14251211plr.120.1588897684116; Thu, 07 May 2020 17:28:04 -0700 (PDT) Received: from lbrmn-lnxub113.broadcom.net ([192.19.228.250]) by smtp.gmail.com with ESMTPSA id gz14sm882677pjb.42.2020.05.07.17.28.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2020 17:28:03 -0700 (PDT) From: Scott Branden To: Luis Chamberlain , Greg Kroah-Hartman , David Brown , Alexander Viro , Shuah Khan , bjorn.andersson@linaro.org, Shuah Khan , Arnd Bergmann Cc: "Rafael J . Wysocki" , linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-fsdevel@vger.kernel.org, BCM Kernel Feedback , Olof Johansson , Andrew Morton , Dan Carpenter , Colin Ian King , Kees Cook , Takashi Iwai , linux-kselftest@vger.kernel.org, Andy Gross , Scott Branden Subject: [PATCH v5 4/7] firmware: test partial file reads of request_firmware_into_buf Date: Thu, 7 May 2020 17:27:36 -0700 Message-Id: <20200508002739.19360-5-scott.branden@broadcom.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200508002739.19360-1-scott.branden@broadcom.com> References: <20200508002739.19360-1-scott.branden@broadcom.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add firmware tests for partial file reads of request_firmware_into_buf. Signed-off-by: Scott Branden --- .../selftests/firmware/fw_filesystem.sh | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/tools/testing/selftests/firmware/fw_filesystem.sh b/tools/testing/selftests/firmware/fw_filesystem.sh index fcc281373b4d..38e89ba1b4d3 100755 --- a/tools/testing/selftests/firmware/fw_filesystem.sh +++ b/tools/testing/selftests/firmware/fw_filesystem.sh @@ -149,6 +149,26 @@ config_unset_into_buf() echo 0 > $DIR/config_into_buf } +config_set_buf_size() +{ + echo $1 > $DIR/config_buf_size +} + +config_set_file_offset() +{ + echo $1 > $DIR/config_file_offset +} + +config_set_partial() +{ + echo 1 > $DIR/config_partial +} + +config_unset_partial() +{ + echo 0 > $DIR/config_partial +} + config_set_sync_direct() { echo 1 > $DIR/config_sync_direct @@ -207,6 +227,35 @@ read_firmwares() done } +read_firmwares_partial() +{ + if [ "$(cat $DIR/config_into_buf)" == "1" ]; then + fwfile="${FW_INTO_BUF}" + else + fwfile="${FW}" + fi + + if [ "$1" = "xzonly" ]; then + fwfile="${fwfile}-orig" + fi + + # Strip fwfile down to match partial offset and length + partial_data="$(cat $fwfile)" + partial_data="${partial_data:$2:$3}" + + for i in $(seq 0 3); do + config_set_read_fw_idx $i + + read_firmware="$(cat $DIR/read_firmware)" + + # Verify the contents are what we expect. + if [ $read_firmware != $partial_data ]; then + echo "request #$i: partial firmware was not loaded" >&2 + exit 1 + fi + done +} + read_firmwares_expect_nofile() { for i in $(seq 0 3); do @@ -319,6 +368,21 @@ test_batched_request_firmware_into_buf() echo "OK" } +test_batched_request_firmware_into_buf_partial() +{ + echo -n "Batched request_firmware_into_buf_partial() $2 off=$3 size=$4 try #$1: " + config_reset + config_set_name $TEST_FIRMWARE_INTO_BUF_FILENAME + config_set_into_buf + config_set_partial + config_set_buf_size $4 + config_set_file_offset $3 + config_trigger_sync + read_firmwares_partial $2 $3 $4 + release_all_firmware + echo "OK" +} + test_batched_request_firmware_direct() { echo -n "Batched request_firmware_direct() $2 try #$1: " @@ -371,6 +435,22 @@ for i in $(seq 1 5); do test_batched_request_firmware_into_buf $i normal done +for i in $(seq 1 5); do + test_batched_request_firmware_into_buf_partial $i normal 0 10 +done + +for i in $(seq 1 5); do + test_batched_request_firmware_into_buf_partial $i normal 0 5 +done + +for i in $(seq 1 5); do + test_batched_request_firmware_into_buf_partial $i normal 1 6 +done + +for i in $(seq 1 5); do + test_batched_request_firmware_into_buf_partial $i normal 2 10 +done + for i in $(seq 1 5); do test_batched_request_firmware_direct $i normal done -- 2.17.1