From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:4001:c0b::241; helo=mail-it0-x241.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-it0-x241.google.com (mail-it0-x241.google.com [IPv6:2607:f8b0:4001:c0b::241]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 30623209603C5 for ; Mon, 21 May 2018 01:58:31 -0700 (PDT) Received: by mail-it0-x241.google.com with SMTP id e20-v6so20294560itc.1 for ; Mon, 21 May 2018 01:58:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=wjzwVABOFOPdsKP/NCKMZ+MJ0Ge26TON4VerHo0AQOI=; b=Hx3PNSv2Ga1yQFl2eq+kCM45qwBbtPEGRAGQDaNeLqp6P/29Jtksy5vAggHy9G4Hvz R9ZPUxdgtUSbumsG09JhwC9dcD95Czy0p3w5JoIri0UHl1O4dVkexj2U2ErIPkBBrpeC eHJnkgfi0Q9vEyNmsY9+iZinw3Vxtrf7Xgxv4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=wjzwVABOFOPdsKP/NCKMZ+MJ0Ge26TON4VerHo0AQOI=; b=mhTELgB8wSPbwAOLPA/IAtKNa7N92KhEE56MaXIFdOWXknZalqrvKE6uuv//OaL23m s2vR0PzRAOPSjKZoGRmasTz4auQ7h4BMIQhmGiYCwc0/Pdl5WVyyCuCienfbJxGvKD7p SkmFyKO9Uj2+Tvu1jku/cpHBhJJQlI6nu21ieWFoQgf9mC/FYupf6TQgUqEupkZ24K/R kHxpr1j4HhH60racDJ1Jj7wyszxXKkcRjQsjSD+2pM87vq1yHm/yNM+cuI5bmC9ZcuD/ AUgEmOeVPrf1oTqVZXtKnHCryMFmJH/DOEBw3brAAMYGKyI9MQr8XSQV2sKssehefCDM LWyw== X-Gm-Message-State: ALKqPwcgmaftrdhH9DBIMoiQiVQdqoMweI5NtZPshxbQrC0yfEkir23Z 0b2Y3ebKG84L10WfmEFM8Twf+aWUBiK4qAn1IjiADg== X-Google-Smtp-Source: AB8JxZr5czQQjrGW/hGNRO2DJvm949ek4XL5xINOZdXPQ6XY+RdE4OkcmNt1UY+KSDRrTOBPzaqmw5ankj8EQHmqXsU= X-Received: by 2002:a24:af45:: with SMTP id l5-v6mr16779031iti.106.1526893110410; Mon, 21 May 2018 01:58:30 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.187.134 with HTTP; Mon, 21 May 2018 01:58:30 -0700 (PDT) In-Reply-To: <1526891152-18739-5-git-send-email-thomas.abraham@arm.com> References: <1526891152-18739-1-git-send-email-thomas.abraham@arm.com> <1526891152-18739-5-git-send-email-thomas.abraham@arm.com> From: Ard Biesheuvel Date: Mon, 21 May 2018 10:58:30 +0200 Message-ID: To: Thomas Abraham Cc: "edk2-devel@lists.01.org" , Leif Lindholm , Daniil Egranov Subject: Re: [PATCH edk2-platforms v4 4/9] Platform/ARM/Sgi: add support for virtio block device X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 May 2018 08:58:31 -0000 Content-Type: text/plain; charset="UTF-8" On 21 May 2018 at 10:25, Thomas Abraham wrote: > From: Daniil Egranov > > Add the registration of the virtio block device. > > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Daniil Egranov > Signed-off-by: Thomas Abraham > --- > .../ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c | 18 ++++- > .../ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf | 1 + > .../ARM/SgiPkg/Drivers/PlatformDxe/VirtioBlockIo.c | 76 ++++++++++++++++++++++ > 3 files changed, 94 insertions(+), 1 deletion(-) > create mode 100644 Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioBlockIo.c > > diff --git a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c > index eb26fde..fb1e390 100644 > --- a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c > +++ b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.c > @@ -15,11 +15,27 @@ > #include > > EFI_STATUS > +InitVirtioBlockIo ( > + IN EFI_HANDLE ImageHandle > +); > + > +EFI_STATUS > EFIAPI > ArmSgiPkgEntryPoint ( > IN EFI_HANDLE ImageHandle, > IN EFI_SYSTEM_TABLE *SystemTable > ) > { > - return EFI_SUCCESS; > + EFI_STATUS Status; > + > + // Install Virtio Block IO. > + if (FeaturePcdGet (PcdVirtioSupported) == TRUE) { No need to compare booleans with TRUE or FALSE. > + Status = InitVirtioBlockIo (ImageHandle); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "PlatformDxe: Failed to install Virtio Block IO\n")); > + return Status; > + } > + } > + > + return Status; > } > diff --git a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf > index dbe04c5..995f80d 100644 > --- a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf > +++ b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/PlatformDxe.inf > @@ -20,6 +20,7 @@ > > [Sources.common] > PlatformDxe.c > + VirtioBlockIo.c > > [Packages] > ArmPkg/ArmPkg.dec > diff --git a/Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioBlockIo.c b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioBlockIo.c > new file mode 100644 > index 0000000..58dfd22 > --- /dev/null > +++ b/Platform/ARM/SgiPkg/Drivers/PlatformDxe/VirtioBlockIo.c > @@ -0,0 +1,76 @@ > +/** @file > + > + Copyright (c) 2018, ARM Ltd. All rights reserved.
> + > + This program and the accompanying materials are licensed and made available > + under the terms and conditions of the BSD License which accompanies this > + distribution. The full text of the license may be found at > + http://opensource.org/licenses/bsd-license.php > + > + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, > + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. > + > +**/ > + > +#include > +#include > +#include > +#include > +#include > + > +#pragma pack (1) > +typedef struct { > + VENDOR_DEVICE_PATH Vendor; > + EFI_DEVICE_PATH_PROTOCOL End; > +} VIRTIO_BLK_DEVICE_PATH; > +#pragma pack () > + > +STATIC VIRTIO_BLK_DEVICE_PATH mVirtioBlockDevicePath = > +{ > + { > + { > + HARDWARE_DEVICE_PATH, > + HW_VENDOR_DP, > + { > + (UINT8)( sizeof (VENDOR_DEVICE_PATH) ), > + (UINT8)( (sizeof (VENDOR_DEVICE_PATH) ) >> 8) No spaces after ( or before ) please > + } > + }, > + EFI_CALLER_ID_GUID, > + }, > + { > + END_DEVICE_PATH_TYPE, > + END_ENTIRE_DEVICE_PATH_SUBTYPE, > + { > + sizeof (EFI_DEVICE_PATH_PROTOCOL), > + 0 > + } > + } > +}; > + > +/** > + * Entrypoint for 'VirtioBlockIo' driver > + */ > +EFI_STATUS > +InitVirtioBlockIo ( > + IN EFI_HANDLE ImageHandle > + ) > +{ > + EFI_STATUS Status = 0; > + > + Status = gBS->InstallProtocolInterface (&ImageHandle, > + &gEfiDevicePathProtocolGuid, EFI_NATIVE_INTERFACE, > + &mVirtioBlockDevicePath); > + Please use correct indentation. > + if (EFI_ERROR (Status)) { > + return Status; > + } > + > + // Declare the Virtio BlockIo device > + Status = VirtioMmioInstallDevice (SGI_EXP_SYSPH_VIRTIO_BLOCK_BASE, ImageHandle); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "PlatformDxe: Failed to install Virtio block device\n")); > + } > + Please handle this error correctly. If the call to VirtioMmioInstallDevice() fails, you will exit this function and hence the DXE entry point with an error, which will result in the driver to be unloaded. However, you just installed gEfiDevicePathProtocolGuid with references to the driver's code, and attempts to invoke those will result in a crash after this. > + return Status; > +} > -- > 2.7.4 >