From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 1BC8D7803E0 for ; Wed, 31 Jan 2024 17:46:16 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=1Fq6y3gRMCE/yq3nqfc1A5gwD+EP5DtjTAMdd0KsFpU=; c=relaxed/simple; d=groups.io; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject:To:Cc:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Type:Content-Transfer-Encoding; s=20140610; t=1706723175; v=1; b=UMZXzEUrg/4whltmImpPyFMGdapA6afHwV3Nt1G2gT/7SFRXMMJsyCauaMrNHCgM1IYTPtOo pnuaL6z5wQhwmnEehMoWdayTfKiciC/3RCS9/iiSuKegVIL3XAYZ5JTlDP1xx0gCgPbEP6kIeGs BEOL/jJbPkJsHzcBPClDTkec= X-Received: by 127.0.0.2 with SMTP id BGKEYY7687511xO5tfa6Do0a; Wed, 31 Jan 2024 09:46:15 -0800 X-Received: from mail-vk1-f175.google.com (mail-vk1-f175.google.com [209.85.221.175]) by mx.groups.io with SMTP id smtpd.web11.1494.1706723175124237559 for ; Wed, 31 Jan 2024 09:46:15 -0800 X-Received: by mail-vk1-f175.google.com with SMTP id 71dfb90a1353d-4bda5740d2dso32470e0c.1 for ; Wed, 31 Jan 2024 09:46:15 -0800 (PST) X-Gm-Message-State: IMta6sv2IrOIDnscX5s7TexOx7686176AA= X-Google-Smtp-Source: AGHT+IHbWZopYZAUgwHwYU+etGPG/zMWflQpQWgMxlGDhI6Xfzy5NULbvQCMIFrIkS96j6hCZbzvpCZMF/Zs8R4YVCU= X-Received: by 2002:a05:6122:4a18:b0:4b6:d63c:ca8f with SMTP id ez24-20020a0561224a1800b004b6d63cca8fmr1925707vkb.16.1706723174044; Wed, 31 Jan 2024 09:46:14 -0800 (PST) MIME-Version: 1.0 References: <20240126062715.3099433-1-lichao@loongson.cn> <20240126062919.3101691-1-lichao@loongson.cn> <3fe0fda8-d32e-679e-2f71-6cc35e7772b8@redhat.com> In-Reply-To: <3fe0fda8-d32e-679e-2f71-6cc35e7772b8@redhat.com> From: "Pedro Falcato" Date: Wed, 31 Jan 2024 17:46:02 +0000 Message-ID: Subject: Re: [edk2-devel] [PATCH v8 14/37] UefiCpuPkg: Add CpuMmuLib to UefiCpuPkg To: Laszlo Ersek Cc: devel@edk2.groups.io, lichao@loongson.cn, Eric Dong , Ray Ni , Rahul Kumar , Gerd Hoffmann , Baoqi Zhang , Dongyan Qian , Xianglai Li , Bibo Mao Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,pedro.falcato@gmail.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=UMZXzEUr; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io On Wed, Jan 31, 2024 at 1:41=E2=80=AFPM Laszlo Ersek wr= ote: > > Hi Pedro, > > On 1/31/24 11:33, Pedro Falcato wrote: > > On Fri, Jan 26, 2024 at 6:29=E2=80=AFAM Chao Li wr= ote: > >> > >> Add a new library named CpuMmuLib and add a LoongArch64 instance with = in > >> the library. > >> It provides two-stage MMU libraryinstances, PEI and DXE. > >> > >> BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4584 > >> [...] > >> diff --git a/UefiCpuPkg/Library/CpuMmuLib/LoongArch64/CommonMmuLib.c b= /UefiCpuPkg/Library/CpuMmuLib/LoongArch64/CommonMmuLib.c > >> new file mode 100644 > >> index 0000000000..2e852c3371 > >> --- /dev/null > >> +++ b/UefiCpuPkg/Library/CpuMmuLib/LoongArch64/CommonMmuLib.c > >> @@ -0,0 +1,988 @@ > >> +/** @file > >> + > >> + CPU Memory Map Unit Handler Library common functions. > >> + > >> + Copyright (c) 2024 Loongson Technology Corporation Limited. All rig= hts reserved.
> >> + > >> + SPDX-License-Identifier: BSD-2-Clause-Patent > >> + > >> + @par Glossary: > >> + - Pgd or Pgd or PGD - Page Global Directory > >> + - Pud or Pud or PUD - Page Upper Directory > >> + - Pmd or Pmd or PMD - Page Middle Directory > >> + - Pte or pte or PTE - Page Table Entry > >> + - Val or VAL or val - Value > >> + - Dir - Directory > >> +**/ > > > > You took essentially Linux code [...] and EDK2-ify'd it. Congrats, > > this is cursed. > > are you saying this patch is effectively a port of GPL'd Linux code > (potentially *old* code, but still), with the GPL simply replaced with > BSD-2-Clause-Patent? Yes. With a bit of patience, you can get a good idea of the similarities by kernel-ifying identifiers and searching them on https://elixir.bootlin.com/linux/latest/source. The smoking gun being the types and strategy used for the MMU code (PGD, P4D, PUD, PMD, PTE and VAL/PTEVAL being a very unique linux strategy that is not emulated elsewhere AFAIK) and SWAP_PAGE_DIR (-> swapper_pg_dir, the kernel's pgd; swap has no meaning whatsoever in UEFI land). > > That sounds... shocking. If such a patch were merged into edk2, it would > violate both the GPL (the GPL cannot just be "relaxed") and the edk2 > rules (edk2 does not want GPL code). > > The only exception would be if Loongson Technology Corporation Limited > were the Copyright holder of the Linux code, and this patch were a > relicensing. But then that too would have to be documented, IMO. FWIW, I wasn't objecting to the patch on legal grounds, but mainly technical ones, since I was assuming Loongson had written most of this code. However (arch/loongarch/include/asm/pgtable.h): /* SPDX-License-Identifier: GPL-2.0 */ /* * Copyright (C) 2020-2022 Loongson Technology Corporation Limited * * Derived from MIPS: * Copyright (C) 1994, 95, 96, 97, 98, 99, 2000, 2003 Ralf Baechle * Copyright (C) 1999, 2000, 2001 Silicon Graphics, Inc. */ and after a closer look, other functions such as P*AllocGet() mirroring p4d_alloc, pud_alloc and pmd_alloc (from include/linux/mm.h, definitely not loongson's copyright) very closely, it seems like this patch is a walking copyright violation. Not that implementing something similar to Linux's is impossible in a clean-room instance, but the code used and the patterns used imitate Linux's down to a t. --=20 Pedro -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#114911): https://edk2.groups.io/g/devel/message/114911 Mute This Topic: https://groups.io/mt/103971653/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-