Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp4711346ybv; Mon, 17 Feb 2020 04:30:15 -0800 (PST) X-Google-Smtp-Source: APXvYqxRtd/mTTF3kBtOUzVoW27oG01uuhf8Rrq3HWBiWL1S8yxye+OqUIMStCwShxJuoSPPASRm X-Received: by 2002:a9d:6c01:: with SMTP id f1mr11539132otq.133.1581942615566; Mon, 17 Feb 2020 04:30:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581942615; cv=none; d=google.com; s=arc-20160816; b=MUrfMaDKW68lhX0sizC37lUhZKihkOiXG3eIZVlMFjV+kq+Z7lFtt8OqzOCS070TBA /KbFMlZTOHCv6Rbb/xf2pbSR7WevLbMwl8PjClPuF0hKaBglkz7sUJvugS5zHxg7Ow4m D895K7Qs5AHdpohZGswe7D1bK459E+qwYjlsRCd7WxfP48kV+5AIuca/ohAPL8Shju7L IbTrrz1he2vxzePg+urvUoNOI5OgVpZ6t8QvE1zEoA6Qiz7mSQTqock5ybsYoDYgODqm g/Ij2as/U0yG7bvWcLh7HTxwobm4olj+qzbTUhrC8g1wDRXxxe67fALZyShOOjx13Q29 xN0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=T6lGwTZh7mHp1+xNe3270Amp1AhzDEDQq2tbWytRCkc=; b=gDt5C96nKpJqaGzOKGz+6JFvCkXo2Zk6W3F0hnl25938VrBlV5WifFeHD+s8/rB7sz 9jbnX6hlYyiS2ZGc9w8PAMGNoF/mczEq0LrxGu/vh344VKknbuqv9hEIyMHBTV7nwKS3 YnwkOJO5RSLJgp1+dOUp6OKKNSTbjiwg52NeFOF+7dwHIv4jrH77NOx3ev/lCHCU1mp1 ILx/pLSGANUHv2ms0Y5KTP676Etbe9dDyqVOfkEkRIkuXgHdqs1zmdHDGQzqzKrnQF62 E3NWB8gXosWQ339Y572gmoC+K7504nfQMNLv9zJZnM5p1RoOTWNy97I9FAaf3d5nozgv o1wg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xr0RKjXP; 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 c14si114907otn.118.2020.02.17.04.30.02; Mon, 17 Feb 2020 04:30:15 -0800 (PST) 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=xr0RKjXP; 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 S1728615AbgBQLJN (ORCPT + 99 others); Mon, 17 Feb 2020 06:09:13 -0500 Received: from mail-wm1-f65.google.com ([209.85.128.65]:39105 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726826AbgBQLJN (ORCPT ); Mon, 17 Feb 2020 06:09:13 -0500 Received: by mail-wm1-f65.google.com with SMTP id c84so18001029wme.4 for ; Mon, 17 Feb 2020 03:09:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=T6lGwTZh7mHp1+xNe3270Amp1AhzDEDQq2tbWytRCkc=; b=xr0RKjXPVB+gRMbXfexYJNKjyWWOmWW1mV7pdgRe9rbLdRCTO7bxfxbB3RwTUZACDH LC23a15L1dYMi/FvFeXO4Ab3APGymTX7wpNiPQNR/rJ+XbS4NRNIrS5iGb+/s8dXyxq3 nJIp/RZHptbqhL91IkiPR1Q8Lb7a2bL+wwDax9bViLe375QUVxC5xYMPzfrTvJSN/jPQ V7GuOtfoyH/3rOnTx3uaNg4o+38tLK0xtCHEJWzC876dHD54ONAsKoIxrbzjUxGwktK8 qkmR2b2HB8vZD9IenM9u0qOu91wVN9zi7aZ6qd+uF4u94zyciEdlyPHUTgzzLYbjoVdo 8BZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=T6lGwTZh7mHp1+xNe3270Amp1AhzDEDQq2tbWytRCkc=; b=Sl7pStkRV+ngiRHDpNUUkKsP8RorH0fUwkXU3wYgm2Vyka2jzt9YQv1vNaUEqYccNe JScLcgpM3U1JJpxsi+zDe77iYC5BGfzq1Ef8SiURazMzieeUzs0QQ9L8VzlczgnX7jIT wYtA3IpojUP7WLtAyoHgLTl9oXSwUaimv0xCAZDVtJgDKIqT6MEMyu6a9Io/O5gAbdvN I2Uku4G8CU/4D/fIpGk1l99Tj5if6abLVgsiUijOsBZvMh976xmwjeFCeyrGL9Q/HJ6I 1lDl4ZkN47c7rETOTkRITgXc829VMsBg5W5Bnh1WDy17lqAGzpUPV4OFPCO7ewZzR7XC K6tg== X-Gm-Message-State: APjAAAUPN8sse+VKlgZWMCV+adSsTYXdgcDaKjV1+WwaMARJ5hvGAmEW f7C+CpC21BACMLJ56twhQo9/xw== X-Received: by 2002:a05:600c:214f:: with SMTP id v15mr22120513wml.110.1581937749544; Mon, 17 Feb 2020 03:09:09 -0800 (PST) Received: from apalos.home (ppp-2-87-54-32.home.otenet.gr. [2.87.54.32]) by smtp.gmail.com with ESMTPSA id u8sm178649wmm.15.2020.02.17.03.09.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Feb 2020 03:09:09 -0800 (PST) Date: Mon, 17 Feb 2020 13:09:06 +0200 From: Ilias Apalodimas To: Ard Biesheuvel Cc: Laszlo Ersek , linux-efi , Linux Kernel Mailing List , Leif Lindholm , Peter Jones , Matthew Garrett , Alexander Graf , Heinrich Schuchardt , Daniel Kiper , Arvind Sankar , James Bottomley , Lukas Wunner Subject: Re: [PATCH v2 2/3] efi/libstub: Add support for loading the initrd from a device path Message-ID: <20200217110906.GA147685@apalos.home> References: <20200216141104.21477-1-ardb@kernel.org> <20200216141104.21477-3-ardb@kernel.org> <4e427366-4141-e360-b1da-c5cb37f8092b@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Ard, [...] > > > > + return EFI_INVALID_PARAMETER; > > > > > > Doesn't return EFI_LOAD_ERROR. > > > > > > > + > > > > + dp = (efi_device_path_protocol_t *)&initrd_dev_path; > > > > + status = efi_bs_call(locate_device_path, &lf2_proto_guid, &dp, &handle); > > > > + if (status != EFI_SUCCESS) > > > > + return status; > > > > > > Seems safe (the only plausible error could be EFI_NOT_FOUND). > > > > > > > + > > > > + status = efi_bs_call(handle_protocol, handle, &lf2_proto_guid, > > > > + (void **)&lf2); > > > > + if (status != EFI_SUCCESS) > > > > + return status; > > > > > > Interesting case; this should never fail... but note, if it does, it > > > returns EFI_UNSUPPORTED, not EFI_NOT_FOUND (if the protocol is missing > > > from the handle). > > > > > > > + > > > > + status = efi_call_proto(lf2, load_file, dp, false, &initrd_size, NULL); > > > > + if (status != EFI_BUFFER_TOO_SMALL) > > > > + return EFI_LOAD_ERROR; > > > > + > > > > + status = efi_allocate_pages(initrd_size, &initrd_addr, max); > > > > + if (status != EFI_SUCCESS) > > > > + return status; > > > > > > Not sure about the efi_allocate_pages() wrapper (?); the UEFI service > > > could return EFI_OUT_OF_RESOURCES. > > > > > > > Hmm, guess I was a bit sloppy with the return codes. The important > > thing is that EFI_NOT_FOUND is only returned in the one specifically > > defined case. > > > > For the record [in case no respin+resend is needed for other reasons], > I intend to update the comment block as below, and keep the code as > is: > Yes i think this makes more sense the return codes are already correct and the fallback is properly triggered. For what it's worth Tested-by: Ilias Apalodimas Acked-by: Ilias Apalodimas > > * @load_addr: pointer to store the address where the initrd was loaded > * @load_size: pointer to store the size of the loaded initrd > * @max: upper limit for the initrd memory allocation > - * @return: %EFI_SUCCESS if the initrd was loaded successfully, in > which case > - * @load_addr and @load_size are assigned accordingly > - * %EFI_NOT_FOUND if no LoadFile2 protocol exists on the initrd > - * device path > + * @return: %EFI_SUCCESS if the initrd was loaded successfully, in which > + * case @load_addr and @load_size are assigned accordingly > + * %EFI_NOT_FOUND if no LoadFile2 protocol exists on the initrd > + * device path > + * %EFI_INVALID_PARAMETER if load_addr == NULL or load_size == NULL > + * %EFI_OUT_OF_RESOURCES if memory allocation failed > * %EFI_LOAD_ERROR in all other cases Regards /Ilias