From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1C1C5C433EF for ; Thu, 7 Apr 2022 09:42:31 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 01EA183CAC; Thu, 7 Apr 2022 11:42:18 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b="ahDrtxDw"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 20E0183C08; Thu, 7 Apr 2022 11:41:51 +0200 (CEST) Received: from mail-wm1-x34a.google.com (mail-wm1-x34a.google.com [IPv6:2a00:1450:4864:20::34a]) (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 62BC183C11 for ; Thu, 7 Apr 2022 11:41:43 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=31rFOYgYKBo0r9tB22x55x2v.t53B-s55A2z9A9.uv4E.uv@flex--ascull.bounces.google.com Received: by mail-wm1-x34a.google.com with SMTP id c125-20020a1c3583000000b0038e3f6e871aso1340502wma.8 for ; Thu, 07 Apr 2022 02:41:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=QtPztfDlH5oeg3F4des8kEycZ16Sa7scxFUndRzzjDs=; b=ahDrtxDwPRl83vfPqt4AMtLH0BlPRhkHXPIIwK45wCaC6V3kh/weUyBn3PkGj2w1Kx gRkXQvm9UvocqOTW0MNrWKGGSD80V/HtLwENuhMxczw/cxov1wO5jNjbpPecg6oLNMW9 hpqGUjJ+dMqDwOOkTGjGfIw6Cge9HCkMEyVS7omvuvtRi45fiI0NFghoVqSM7Divs8Mw Z6++iTHDFaZLPoDV8887zndkqBuwH8LWFXuGrSytYD3/p999+JdGbTms5D9c7s4/F2xi Wi+4UTVBqoSxYz0FeHMEkSCS4P/i+LAzj5K1ZIBoDqMquKxLery03S7B3eSlV9+eKUHR GTcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=QtPztfDlH5oeg3F4des8kEycZ16Sa7scxFUndRzzjDs=; b=7ABz3K9cl8QJNwofvr6sttownpwVLLAJJKPGEfkI0+j2A60uvlkc8Xk6gM0SRx+Pl/ oaHVKgyzEMeb8zEiB2ULB7VNLX8zyY6AS6MS2WNZ4LlVMAwmqwtNjWWBuojMGxFGj7LD P540K1e0XCwBWuq5SuamFcPQrEx6kU0zeDgOaGnJTjfMq+Htt40k+AI5rpyCjYyuVN0O HGWyzNztce6dBAP8oKd8KwVwRKzg+rP29mxQLFrJTar/V7251LK713ssa2WyRQQjQUY6 ZDY4hbiNK6cx2ZfcPp8B1lmrviwsx9KOL8ZO3qheHpSzZHYU9M29/H6h+iuBrz5rh2dX BAPQ== X-Gm-Message-State: AOAM531CvhrU5xdSREzhIaHkworSHMc78TSlA316AtsFiZgENOPNEELt nHpkVJdvPESzeAGjV5ybH6K4ilAWJayGG1iAyICkgPCvfCvIp4r5aCg/8C8PFOy+CjIkoqFMNG8 Ybf0FdXt8LMyySbVWNyiURoCAxAQnfQSAZMz2CfisYPgeYqJIXzfwqDriGB0= X-Google-Smtp-Source: ABdhPJwBG0rrCBllMLJCHBnO7kNeT8i2BCRRS/Q+CBszoNXjhLxwM6RtKIEbaki8lOL+Raya+SPUWaJDV8k= X-Received: from ascull.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:1510]) (user=ascull job=sendgmr) by 2002:a5d:410c:0:b0:206:b5c:65c7 with SMTP id l12-20020a5d410c000000b002060b5c65c7mr9801603wrp.94.1649324502822; Thu, 07 Apr 2022 02:41:42 -0700 (PDT) Date: Thu, 7 Apr 2022 09:41:17 +0000 In-Reply-To: <20220407094123.1752236-1-ascull@google.com> Message-Id: <20220407094123.1752236-6-ascull@google.com> Mime-Version: 1.0 References: <20220407094123.1752236-1-ascull@google.com> X-Mailer: git-send-email 2.35.1.1094.g7c7d902a7c-goog Subject: [PATCH 05/11] fuzzing_engine: Add fuzzing engine uclass From: Andrew Scull To: u-boot@lists.denx.de Cc: sjg@chromium.org, seanga2@gmail.com, Andrew Scull Content-Type: text/plain; charset="UTF-8" X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.5 at phobos.denx.de X-Virus-Status: Clean This new class of device will provide fuzzing inputs from a fuzzing engine. Signed-off-by: Andrew Scull --- drivers/Kconfig | 2 + drivers/Makefile | 1 + drivers/fuzzing_engine/Kconfig | 6 +++ drivers/fuzzing_engine/Makefile | 7 +++ .../fuzzing_engine/fuzzing_engine-uclass.c | 28 ++++++++++ include/dm/uclass-id.h | 1 + include/fuzzing_engine.h | 51 +++++++++++++++++++ 7 files changed, 96 insertions(+) create mode 100644 drivers/fuzzing_engine/Kconfig create mode 100644 drivers/fuzzing_engine/Makefile create mode 100644 drivers/fuzzing_engine/fuzzing_engine-uclass.c create mode 100644 include/fuzzing_engine.h diff --git a/drivers/Kconfig b/drivers/Kconfig index b26ca8cf70..54ad7f82fa 100644 --- a/drivers/Kconfig +++ b/drivers/Kconfig @@ -40,6 +40,8 @@ source "drivers/fastboot/Kconfig" source "drivers/firmware/Kconfig" +source "drivers/fuzzing_engine/Kconfig" + source "drivers/fpga/Kconfig" source "drivers/gpio/Kconfig" diff --git a/drivers/Makefile b/drivers/Makefile index 4e7cf28440..10a4a317c9 100644 --- a/drivers/Makefile +++ b/drivers/Makefile @@ -113,6 +113,7 @@ obj-$(CONFIG_W1) += w1/ obj-$(CONFIG_W1_EEPROM) += w1-eeprom/ obj-$(CONFIG_MACH_PIC32) += ddr/microchip/ +obj-$(CONFIG_FUZZ) += fuzzing_engine/ obj-$(CONFIG_DM_HWSPINLOCK) += hwspinlock/ obj-$(CONFIG_DM_RNG) += rng/ endif diff --git a/drivers/fuzzing_engine/Kconfig b/drivers/fuzzing_engine/Kconfig new file mode 100644 index 0000000000..f405fc75e8 --- /dev/null +++ b/drivers/fuzzing_engine/Kconfig @@ -0,0 +1,6 @@ +config DM_FUZZING_ENGINE + bool "Driver support for fuzzing engine devices" + depends on DM + help + Enable driver model for fuzzing engine devices. This interface is + used to get fuzzing inputs from a fuzzing engine. diff --git a/drivers/fuzzing_engine/Makefile b/drivers/fuzzing_engine/Makefile new file mode 100644 index 0000000000..acd894999c --- /dev/null +++ b/drivers/fuzzing_engine/Makefile @@ -0,0 +1,7 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (c) 2022 Google, Inc. +# Written by Andrew Scull +# + +obj-$(CONFIG_DM_FUZZING_ENGINE) += fuzzing_engine-uclass.o diff --git a/drivers/fuzzing_engine/fuzzing_engine-uclass.c b/drivers/fuzzing_engine/fuzzing_engine-uclass.c new file mode 100644 index 0000000000..b16f1c4cfb --- /dev/null +++ b/drivers/fuzzing_engine/fuzzing_engine-uclass.c @@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright (c) 2022 Google, Inc. + * Written by Andrew Scull + */ + +#define LOG_CATEGORY UCLASS_FUZZING_ENGINE + +#include +#include +#include + +int dm_fuzzing_engine_get_input(struct udevice *dev, + const uint8_t **data, + size_t *size) +{ + const struct dm_fuzzing_engine_ops *ops = device_get_ops(dev); + + if (!ops->get_input) + return -ENOSYS; + + return ops->get_input(dev, data, size); +} + +UCLASS_DRIVER(fuzzing_engine) = { + .name = "fuzzing_engine", + .id = UCLASS_FUZZING_ENGINE, +}; diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h index 0e26e1d138..b9411f1d59 100644 --- a/include/dm/uclass-id.h +++ b/include/dm/uclass-id.h @@ -53,6 +53,7 @@ enum uclass_id { UCLASS_ETH, /* Ethernet device */ UCLASS_ETH_PHY, /* Ethernet PHY device */ UCLASS_FIRMWARE, /* Firmware */ + UCLASS_FUZZING_ENGINE, /* Fuzzing engine */ UCLASS_FS_FIRMWARE_LOADER, /* Generic loader */ UCLASS_GPIO, /* Bank of general-purpose I/O pins */ UCLASS_HASH, /* Hash device */ diff --git a/include/fuzzing_engine.h b/include/fuzzing_engine.h new file mode 100644 index 0000000000..357346e93d --- /dev/null +++ b/include/fuzzing_engine.h @@ -0,0 +1,51 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright (c) 2022 Google, Inc. + * Written by Andrew Scull + */ + +#ifndef __FUZZING_ENGINE_H +#define __FUZZING_ENGINE_H + +struct udevice; + +/** + * dm_fuzzing_engine_get_input() - get an input from the fuzzing engine device + * + * The function will return a pointer to the input data and the size of the + * data pointed to. The pointer will remain valid until the next invocation of + * this function. + * + * @dev: fuzzing engine device + * @data: output pointer to input data + * @size output size of input data + * Return: 0 if OK, -ve on error + */ +int dm_fuzzing_engine_get_input(struct udevice *dev, + const uint8_t **data, + size_t *size); + +/** + * struct dm_fuzzing_engine_ops - operations for the fuzzing engine uclass + * + * This contains the functions implemented by a fuzzing engine device. + */ +struct dm_fuzzing_engine_ops { + /** + * @get_input() - get an input + * + * The function will return a pointer to the input data and the size of + * the data pointed to. The pointer will remain valid until the next + * invocation of this function. + * + * @get_input.dev: fuzzing engine device + * @get_input.data: output pointer to input data + * @get_input.size output size of input data + * @get_input.Return: 0 if OK, -ve on error + */ + int (*get_input)(struct udevice *dev, + const uint8_t **data, + size_t *size); +}; + +#endif /* __FUZZING_ENGINE_H */ -- 2.35.1.1094.g7c7d902a7c-goog