From nobody Sun Dec 25 01:46:37 2022 X-Original-To: freebsd-arm@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4NfkL34Ntvz1HWX4 for ; Sun, 25 Dec 2022 01:46:51 +0000 (UTC) (envelope-from hiroo.ono@gmail.com) Received: from mail-pg1-x531.google.com (mail-pg1-x531.google.com [IPv6:2607:f8b0:4864:20::531]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1D4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4NfkL253Q1z3kNx for ; Sun, 25 Dec 2022 01:46:50 +0000 (UTC) (envelope-from hiroo.ono@gmail.com) Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20210112 header.b=Uz6r3uOm; spf=pass (mx1.freebsd.org: domain of hiroo.ono@gmail.com designates 2607:f8b0:4864:20::531 as permitted sender) smtp.mailfrom=hiroo.ono@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-pg1-x531.google.com with SMTP id w37so5453690pga.5 for ; Sat, 24 Dec 2022 17:46:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :reply-to:in-reply-to:references:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=77nlnj/tAB57RxkJkNRQgDB3y6BKB+yRtHiuToYxJyA=; b=Uz6r3uOmvnMs1nuz62cjNtLPpmiSlqq59JGk6uazkaafrRvr/Qf7BRfL8ZloKqK0uv QQXiUp5N3Ez1tZ+8c2gh8IfZDVG+7c05BwAoD8juqbsM0knPZyKsXqkI8tMOcz+QJkE8 NhbiaO4zTuruQD2pbnmbKIZLeww7pI99oo7PcTZss4sPRTO378s/MJglU6HdfbN44g7R sopojHjZY9Neg/ZqubaFfZVF0W9tJFoqbzwv05bcp7Uzi34XtxhVv8ttWSCYOyIIFISY DAUpcDvwzLquYBEpWAoFRWVsKLpyNSbW+iIm502+YYdaztrQNEzKxrRrzznNQHtoRVDJ GlvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :reply-to:in-reply-to:references:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=77nlnj/tAB57RxkJkNRQgDB3y6BKB+yRtHiuToYxJyA=; b=Vs6KBOkBEgUpETsfq4kwUXcVD3Ys54SyGg55DjYWK44cTU6Fmwltp6b+3MQ28qnARi MZQhc58qI6EZyGfpxHFYGJE0zFQhO++hwGoejXExVx8f08vIpbBr86p9iCGo2PUCWdvR m7Ct2DOh9a7LYibWyFrJhY4GbcPKIjTP3wuTTw6KIuGpTHp0jmESXz9abxdysRRh/a6G 1iai1ZBFyUhG/NLu0iLcRM+DMkgxOZ60PPeB33v3TG3s7/892XSfKrLf+m5uBrtAZjQ3 /ELDzt8HPlJHdvDhE3k2ZzlADfUNTfPPJz35MGtKlQ3mmSiT4ITiAdjfyJCJWcAoJKDM 1T+A== X-Gm-Message-State: AFqh2kodnoA7mYwtjFiUms+6pFHeri9b3BkdTj1LpjtVjs9FIL1Fpkt5 /vbmBnuJvGII1KcecjCT9AYlNNTUPCtZMwpeFUHYntOXUuA= X-Google-Smtp-Source: AMrXdXu0NXlAOG2TTRgo40RV2CnQ+LFQtXFhjSzyZptS9yW8vD1vpIVzhvtR8NGbupVDqtsw82Ge7DKKHUy1jhBLF1w= X-Received: by 2002:aa7:9202:0:b0:574:5c9e:c1f2 with SMTP id 2-20020aa79202000000b005745c9ec1f2mr1095680pfo.52.1671932809323; Sat, 24 Dec 2022 17:46:49 -0800 (PST) List-Id: Porting FreeBSD to ARM processors List-Archive: https://lists.freebsd.org/archives/freebsd-arm List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-arm@freebsd.org MIME-Version: 1.0 References: In-Reply-To: Reply-To: hiroo.ono+freebsd@gmail.com From: =?UTF-8?B?SGlyb28gT25vICjlsI/ph47lr5vnlJ8p?= Date: Sun, 25 Dec 2022 10:46:37 +0900 Message-ID: Subject: Re: Still did not succeed to boot on Lenovo Yoga C630 To: Warner Losh Cc: Mark Millard , freebsd-arm@freebsd.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spamd-Result: default: False [-3.39 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-0.997]; NEURAL_HAM_LONG(-0.78)[-0.783]; NEURAL_HAM_SHORT(-0.60)[-0.605]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20210112]; R_SPF_ALLOW(-0.20)[+ip6:2607:f8b0:4000::/36:c]; MIME_GOOD(-0.10)[text/plain]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; RCVD_COUNT_TWO(0.00)[2]; RCVD_IN_DNSWL_NONE(0.00)[2607:f8b0:4864:20::531:from]; PREVIOUSLY_DELIVERED(0.00)[freebsd-arm@freebsd.org]; FREEMAIL_REPLYTO(0.00)[gmail.com]; MLMMJ_DEST(0.00)[freebsd-arm@freebsd.org]; TO_MATCH_ENVRCPT_SOME(0.00)[]; HAS_REPLYTO(0.00)[hiroo.ono+freebsd@gmail.com]; DWL_DNSWL_NONE(0.00)[gmail.com:dkim]; FREEMAIL_CC(0.00)[yahoo.com,freebsd.org]; REPLYTO_ADDR_EQ_FROM(0.00)[]; MID_RHS_MATCH_FROMTLD(0.00)[]; FREEMAIL_FROM(0.00)[gmail.com]; TO_DN_SOME(0.00)[]; ARC_NA(0.00)[]; DKIM_TRACE(0.00)[gmail.com:+]; MIME_TRACE(0.00)[0:+]; TAGGED_FROM(0.00)[freebsd]; FROM_EQ_ENVFROM(0.00)[]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; FREEMAIL_ENVFROM(0.00)[gmail.com]; RCVD_TLS_LAST(0.00)[] X-Rspamd-Queue-Id: 4NfkL253Q1z3kNx X-Spamd-Bar: --- X-ThisMailContainsUnwantedMimeParts: N 2022=E5=B9=B412=E6=9C=8824=E6=97=A5(=E5=9C=9F) 10:03 Warner Losh : > > > > On Fri, Dec 23, 2022 at 5:49 PM Hiroo Ono (=E5=B0=8F=E9=87=8E=E5=AF=9B=E7= =94=9F) wrote: >> >> The current status of FreeBSD 14-current on Lenovo Yoga C630 is as follo= ws: >> >> 1) Merging from OpenBSD's loader code made the loader boot apart from >> 3 points (#2 to 4 ). >> 2) when comconsole->c_init() runs the 2nd time, it seems to freeze. >> (might be C630 specific) >> 3) SetVirtualAddressMap() in efi_do_vmap() freezes. (might also >> affect other snapdragon systems like Microsoft Arm Developer Kit) >> 4) The kernel is kicked but does not start. >> >> 1) is quite straightforward. What needs to be changed is >> stand/efi/loader/arch/arm64/start.S. > > > Can you share what needs to be done? To my eye, we don't need any changes= , so it would be good to know what you've had to do exactly. > >> >> For 2), I do not know what to do. Currently, I commented out >> comconsole from struct console *consoles[] in stand/efi/loader/conf.c >> as a workaround. Maybe, I should write a fault handler that helps >> returning from the fault. > > > There were problems with this with HyperV on aarch64 too. > > Something like > diff --git a/stand/efi/loader/efiserialio.c b/stand/efi/loader/efiseriali= o.c > index 8b3f8e83e0b3..54ee39096685 100644 > --- a/stand/efi/loader/efiserialio.c > +++ b/stand/efi/loader/efiserialio.c > @@ -261,11 +261,11 @@ comc_probe(struct console *sc) > if (comc_port =3D=3D NULL) > return; > } > - comc_port->baudrate =3D COMSPEED; > + comc_port->baudrate =3D 0; > comc_port->ioaddr =3D 0; /* default port */ > - comc_port->databits =3D 8; /* 8,n,1 */ > - comc_port->parity =3D NoParity; /* 8,n,1 */ > - comc_port->stopbits =3D OneStopBit; /* 8,n,1 */ > + comc_port->databits =3D 0; /* 8,n,1 */ > + comc_port->parity =3D 0; /* 8,n,1 */ > + comc_port->stopbits =3D 0; /* 8,n,1 */ > comc_port->ignore_cd =3D 1; /* ignore cd */ > comc_port->rtsdtr_off =3D 0; /* rts-dtr is on */ > comc_port->sio =3D NULL; > > was needed. Possibly the following would be better: > > diff --git a/stand/efi/loader/efiserialio.c b/stand/efi/loader/efiseriali= o.c > index 8b3f8e83e0b3..54ee39096685 100644 > --- a/stand/efi/loader/efiserialio.c > +++ b/stand/efi/loader/efiserialio.c > @@ -494,8 +494,7 @@ comc_setup(void) > return (false); > > status =3D comc_port->sio->SetAttributes(comc_port->sio, > - comc_port->baudrate, 0, 0, comc_port->parity, > - comc_port->databits, comc_port->stopbits); > + 0, 0, 0, 0, 0, 0); > if (EFI_ERROR(status)) > return (false); Following change could avoid freeze in comconsole->c_init(). ---------- --- a/stand/efi/loader/efiserialio.c +++ b/stand/efi/loader/efiserialio.c @@ -467,8 +467,10 @@ comc_speed_set(struct env_var *ev, int flags, const void *value) if (comc_parse_intval(value, &speed) !=3D CMD_OK) return (CMD_ERROR); - comc_port->baudrate =3D speed; - (void) comc_setup(); + if (comc_port->baudrate !=3D speed) { + comc_port->baudrate =3D speed; + (void) comc_setup(); + } env_setenv(ev->ev_name, flags | EV_NOHOOK, value, NULL, NULL); ---------- comc_speed_set sets new speed to comc_port->baudrate and calls comc_setup()= . But if the new value of comc_port->baudrate is same as the previous one, comc_setup() freezes at status =3D comc_port->sio->GetControl(comc_port->sio, &control); Now, the remaining problem is that the kernel does not start. Linux and OpenBSD run on the machine, so there should be a solution... >> 3), I dumped each memory map's VirtualStart and PhysicalStart. All >> VirtualStart were 0. So overwriting VirutalStart by the value of >> PhysicalStart and running SetVirtualAddressMap should work. But in >> reality, it doesn't. >> OpenBSD does not use SetVirtualAddress for arm64 and Linux seems to >> have abandoned it for arm64 in 2019. >> https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git/commit/?= id=3D4e46c2a956215482418d7b315749fb1b6c6bc224 >> Maybe, we also can avoid SetVirtualAddressMap (by >> efi_disable_vmap=3D"YES"). In this case, (as you wrote) I should change >> the kernel to treat VA=3D=3DPA if VirtualStart is 0. (OpenBSD seems to d= o >> so). > > > FreeBSD tends to prefer this... Our kernel needs to cope with cases where= it has > been called (many kexec environments provide PA !=3D VA virtual mappings = that we > can't change). > >> >> About 4), I am completely confused. In elf64_exec in >> stand/efi/loader/arch/arm64/exec.c, the memory address that the kernel >> was loaded is calculated as: >> entry =3D efi_translate(ehdr->e_entry); // which becomes 0xb340000 >> and later kicked as: >> (*entry)(modulep); >> I wrote that this calculation is doubtful, but it was right. I dumped >> the data at the address 0xb340000 and compared it with the output of >> objdump -D loader_lua.syms. It turned out that it matched with the >> kernel's _start code in locore.S. >> Putting some code that jumps to loader's ImageBase address at the >> start of kernel's _start did not change anything, so I judged that the >> kernel is not started at all. >> The excerpt of the loader's memmap command output is as follows: >> Type Physical Virtual #Pages At= tr >> LoaderData 0000b33ea000 000000000000 00000000 UC WC WT WB WP RP X= P >> LoaderCode 0000bb909000 000000000000 000000d1 UC WC WT WB WP RP XP >> From this output, I wonder if the memory attributes on Yoga C630 is >> properly implemented, but as XP (exec protect) bit is on, I tried to >> set it off by DXE services' SetMemoryAttributes() (with a lot of >> transcription from the standards...).It succeeded, but the kernel >> still did not run. >> >> From this tweet: >> https://twitter.com/canadianbryan/status/1598053941270679552 and its >> replies, the Microsoft Arm Developer Kit seems to have similar >> problem, so if somebody succeeded to run FreeBSD on it, please share >> the information how to do it. > > > I run other arm64 machines w/o issue with the current code. I've not hear= d from Allan > for his changes, nor seen any reviews come through... > > Where can one buy one of these systems. It seems just odd-ball enough tha= t I can > justify picking one up for work... Currently, a Snapdragon system easy to purchase is the Microsoft Arm Developer Kit, I suppose. It is about $600. For laptops, Qualcomm has a list: https://www.qualcomm.com/products/application/mobile-computing/laptop-devic= e-finder > Warner