Chongzhi314

@Jimmy-Xu

Joined on Sep 7, 2024

  • contributed by < JimmyChongz > 任務簡述 依循 ktcp 作業規範,進行作業,務必提交給進 khttpd 的 pull request 並接受 review,過程中善用 eBPF 相關工具來追蹤封包並詳實紀錄。 理解 kecho 的運作 追蹤程式碼 當掛載 kecho.ko 時,會執行: open_listen: 建立並配置一個 TCP 伺服器 socket,準備接受客戶端連接。sock_create: 用於建立 socket,包含記憶體分配。TODO: 追蹤 Linux 源碼 linux/net/socket.cPF_INET: IPv4 協定
     Like  Bookmark
  • Module 1 secure shell headless disconnect keyboard, mouse and screen Secure SHell deamon (SSHD) Deamon is a generic term on Unix Linux machines that is just a process that is forever running in the background waiting for something happen. How to get your Raspberry Pi IP address ? $ ifconfig
     Like  Bookmark
  • contributed by <JimmyChongz> 安裝 Ubuntu 24.04 在 Windows 11 安裝 Ubuntu 24.04.1 LTS 環境 $ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 24.04.2 LTS
     Like  Bookmark
  • Q1: kxo -> 為何 Linux 核心不傾向使用 FPU? 參考 Use of floating point in the Linux kernel: The real reason is that the kernel doesn't particularly need FPU ops and also needs to run on architectures without an FPU at all. Therefore, it simply avoids the complexity and runtime required to manage its own FPU context by not doing ops for which there are always other software solutions. It's interesting to note how often the FPU state would have to be saved if the kernel wanted to use FP...every system call, every interrupt, every switch between kernel threads. Even if there was a need for occasional kernel FP, it would probably be faster to do it in software. 因為 FPU 暫存器較大(如:Intel x86 的 YMM 暫存器一個就有 256 bits 寬 [Source]),且作業系統又需經常進行 Context Switch (如:system call, interrupt, switch between kernel threads),因此若在 kernel 中使用 FPU 指令,每次都要反覆的「手動^[1]^」store 和 restore FPU 暫存器狀態,這會需要更多的 CPU cycle,導致系統效能下降,何況大多數核心程式碼幾乎不會使用浮點數指令,而且 Linux kernel 還得能在缺少 FPU 的硬體(如:較早期的嵌入式處理器)上運行。所以若為這些不常使用 FPU 的行程頻繁 store 和 restore FPU 狀態是非常浪費系統資源的。因此kernel 的浮點數運算改由軟體方法 (如:fixed point) 來取代,雖然軟體方法在浮點數運算的效率沒有直接用 FPU 來的好,但 kernel 少用,所以相比於支援 FPU 的 kernel 來說反而是更快。再者,由於前述的原因,為了減少不必要的 FPU 狀態保存,FPU 支援 lazy state switching 機制,借助此機制可以讓 kernel 在支援 FPU 指令的同時,當發生 Context Switch 時,以 Intel®64 為例,kernel 需將 CR0.TS bit 設為 1 ^[2]^,表示 FPU 暫存器的內容尚未保存,若接手的行程未執行到 FPU 指令,則 FPU 暫存器的內容仍維持上一個行程的 context 的狀態,反之,一但後來的行程一執行到 FPU 指令時,就會因為 CR0.TS bit 為 1 而觸發 trap(Device not Available exception 即 #NM)進入 kernel mode^[實驗]^,此時 #NM exception handler 就會去保存上一個行程的 context 狀態。不過在現今動態執行^[3]^的 CPU 中,可能沒辦法馬上偵測到 lazy restore mechanisms 中設定的 "FPU not available",導致在當前行程中,仍可以存取到上一個行程的 FPU 暫存器內容,進而達到攻擊的目的(FPU 暫存器可能是用來暫存加密相關資料)即 CVE-2018-3665 漏洞。基於上述的種種因素,Linux 不傾向使用 FPU 指令。 實驗: Linux kernel module
     Like  Bookmark
  • contributed by < JimmyChongz > 閱讀〈因為自動飲料機而延畢的那一年〉的啟發 看完作者製作自動飲料機的心路歷程後,我深刻體會到「不輕易放棄」有多難。當困難接踵而至時,選擇放棄很簡單,但我會因為放棄而失去解決問題與累積經驗的機會,若未來有人問我:「在你的求學或工作經驗中,遇過最大的挑戰是什麼?你是如何克服的?」我可能會因為當初的退縮而無話可說。 <s>我覺得這堂課的作業內容對我來說難度頗高</s> ,目前完成度最高的作業是作業一,在寫作業的過程中,我意識到我還有太多東西要補,搞不清楚自己到底要先補哪一個,且我使用 LLM 的機率很高,當我遇到問題時,都習慣先問 LLM,因為它能夠馬上給我「符合邏輯」的解釋,讓我能夠免強跟上作業繳交進度,但這就是為了交作業而交作業,並沒有真的學到東西,這部分我需要改變心態,應先把一件事做好再做另一件事。 學期初受指導教授指派擔任物聯網課程 Network Programming 的助教,需說明 socket interface 概念以及帶領學生透過樹莓派做 client & server 相關的實驗,有花費一些時間在看 Socket Interface 相關的內容,且 server 要能夠服務多個 client,需要對 server 做多執行緒(I/O)的設計,因此內容就應涉及 pthread, select 或 epoll 的概念。所以,針對期末專題我希望是完成第六次作業 khttpd 或參與類似 以 eBPF 建構 TCP 伺服器 的專案。 :::info
     Like  Bookmark
  • C 語言規格書 Data Types 資料型態 Size (Byte) 格式 (unsigned) short 2 %d
     Like  Bookmark
  • contributed by < JimmyChongz > :::danger 注意書寫規範! ::: ksort 閱讀 LKMPG 嘗試插入 Hello World Module 到 Kernel 確認 Linux 核心版本
     Like  Bookmark
  • Contributed by <JimmyChongz> Quiz 3 測驗一 Accuracy VS Precision 參考 精度和精度 (Accuracy and Precision) Accuracy 準確度測量出的數據有多接近正確的數值 Precision 精密度
     Like  Bookmark
  • contributed by <JimmyChongz> 第一週課堂測驗 測驗一 解釋 list_insert_before 運作原理 老師說明 宣告一個指標 p,指向 head 指標 ~[圖一]~,透過 for 迴圈依序指向每一個節點的 next 指標 (也就是指向下一個 node 的指標),直到 *p (指向下個節點的指標) 為 before 跳出回圈~[圖二]~。此時,將 p 指向的指標 Node2->next(即*p ) 改指向 item~[圖三]~。 圖一:![截圖 2025-02-19 下午3.11.26](https://hackmd.io/_uploads/Ski7NW79yl.png =90%x) list_item_t **p = &l->head;
     Like  Bookmark
  • contributed by <徐崇智> Quiz1 - Problem C C implementation of __builtin_clz :::warning In the case where x = 0, the result is undefined according to the GCC documentation, so we cannot allow 0 to be used as an input to the my_clz function. ::: Example For x = 1Binary representation of 1 is 0000 0000 0000 0000 0000 0000 0000 0001
     Like  Bookmark
  • Part A Mathematical Functions Task 1: ReLU In this part, we need to iterate through the entire input array. For each element in the array that is less than zero, we should change it to zero, ensuring that all elements in the input array are non-negative. Tsak 2: ArgMax In this approach, we begin by assuming the first element of the input array is the maximum value. Starting from the second element, we iterate through each element in the array. At each step, we compare the current element with the current maximum value. If the current element is larger, we update the maximum value accordingly. This process continues until we have examined all elements in the array, leaving us with the maximum value of the input array. Task 3.1: Dot Product In this section, there are two input arrays, and we need to calculate the precise offset for each element in the arrays. It’s important to also consider the stride of each array. For example:
     Like  Bookmark
  • Reference: https://ivonblog.com/posts/windows11-ubuntu2204-dual-boot/ https://ivonblog.com/posts/ubuntu-fcitx5/ 騰出空間來裝 Ubuntu 在不刪除Windows 11資料的情況下安裝Ubuntu,需要準備空間給Ubuntu安裝。 右鍵點選 Windows 圖示,點選磁碟管理。 對目前使用的磁碟(C槽)按右鍵,點選壓縮磁碟。 輸入壓縮 65536 MB ( 1024MB x 64 = 64GB ) 或更多。
     Like  Bookmark
  • contributed by <JimmyChongz>
     Like  Bookmark