Skip to content

Commit

Permalink
Merge pull request #40 from bobuhiro11/refactoring
Browse files Browse the repository at this point in the history
flag, ebda: refactoring code
  • Loading branch information
bobuhiro11 authored Nov 20, 2021
2 parents 2456709 + 6f6ed11 commit 12d81ae
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ bzImage: linux.config linux.tar.xz

.PHONY: run
run: initrd bzImage
# refs: commit 1621292e73770aabbc146e72036de5e26f901e86 in kvmtool
go run . -p "console=ttyS0 earlyprintk=serial noapic noacpi notsc debug apic=debug show_lapic=all mitigations=off lapic dyndbg=\"file arch/x86/kernel/smpboot.c +plf\"" -c 4
go run . -c 4

.PHONY: run-system-kernel
run-system-kernel:
Expand Down
7 changes: 7 additions & 0 deletions ebda/ebda.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package ebda
import (
"bytes"
"encoding/binary"
"fmt"
"unsafe"

"github.com/bobuhiro11/gokvm/bootparam"
Expand All @@ -12,6 +13,8 @@ const (
MaxVCPUs = 64
)

var errorVCPUNumExceed = fmt.Errorf("the number of vCPUs must be less than or equal to %d", MaxVCPUs)

// Extended BIOS Data Area (EBDA).
type EBDA struct {
// padding
Expand Down Expand Up @@ -146,6 +149,10 @@ func NewMPCTable(nCPUs int) (*MPCTable, error) {
m.LAPIC = apicAddr(0)
m.OEMCount = MaxVCPUs // This must be the number of entries

if nCPUs > MaxVCPUs {
return nil, errorVCPUNumExceed
}

var err error

for i := 0; i < nCPUs; i++ {
Expand Down
6 changes: 5 additions & 1 deletion flag/flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@ import (
func ParseArgs(args []string) (string, string, string, int, error) {
kernel := flag.String("k", "./bzImage", "kernel image path")
initrd := flag.String("i", "./initrd", "initrd path")
params := flag.String("p", "console=ttyS0", "kernel command-line parameters")
nCpus := flag.Int("c", 1, "number of cpus")

// refs: commit 1621292e73770aabbc146e72036de5e26f901e86 in kvmtool
params := flag.String("p", `console=ttyS0 earlyprintk=serial noapic noacpi notsc `+
`debug apic=debug show_lapic=all mitigations=off lapic `+
`dyndbg="file arch/x86/kernel/smpboot.c +plf"`, "kernel command-line parameters")

flag.Parse()

if err := flag.CommandLine.Parse(args[1:]); err != nil {
Expand Down

0 comments on commit 12d81ae

Please sign in to comment.